【发布时间】:2021-10-18 23:17:00
【问题描述】:
嘿,所以我正在使用带有 nodejs 和 nginx 的套接字 io,但我无法让我的网站工作,我正在进入单个页面的重定向循环。我在这里发布我的 nginx 配置,希望我们能找到问题..任何人都可以帮助我解决这个问题吗?使用 apache 我可以打开网站,但 nodejs 连接没有显示在客户端,所以我使用的是 nginx ..
upstream nodejs {
server 127.0.0.1:8000;
}
#
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name localhost;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
#fastcgi_pass unix:/var/run/php7-4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location /app-socket {
proxy_pass http://nodejs/socket.io;
proxy_redirect off;
}
location /socket.io {
proxy_pass http://nodejs/socket.io;
proxy_redirect off;
}
location / {
try_files $uri /index.php =404;
#fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
#fastcgi_index index.php;
include fastcgi_params;
}
}
【问题讨论】: