我没有使用过 NGINX,但使用 Apache 已有 12 年左右的经验。我不知道我为什么会在这个运行 NGINX 的服务器上遇到问题,但我正在努力充分利用它。
无论如何,无论我做什么,访问 www.example.com/some-path 总是会将我带到 example.com(无路径),但访问 example.com/some-path 则没问题。有办法解决这个问题吗?如果我不尽快解决这个问题,客户会杀了我的!
谢谢!
编辑:这是 NGINX 配置
#user nginx;
worker_processes 1;
#error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
#pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#tcp_nodelay on; include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#tcp_nodelay on;
#gzip on;
#gzip_disable "MSIE [1-6]\.(?!.*SV1)";
server_tokens off;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
再次编辑: 配置文件
#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.
include /etc/nginx/plesk.conf.d/server.conf;
include /etc/nginx/plesk.conf.d/webmail.conf;
include /etc/nginx/plesk.conf.d/vhosts/*.conf;
include /etc/nginx/plesk.conf.d/forwarding/*.conf;
include /etc/nginx/plesk.conf.d/wildcards/*.conf;
服务器配置文件
#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.
include "/etc/nginx/plesk.conf.d/ip_default/*.conf";
server {
listen [my ip, hidden for security]:80;
location / {
proxy_pass http://[my ip, hidden for security]:7080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen [my ip, hidden for security]:443 ssl;
ssl_certificate /opt/psa/var/certificates/certWLTI39G;
ssl_certificate_key /opt/psa/var/certificates/certWLTI39G;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass https://[my ip, hidden for security]:7081;
proxy_set_header Host $host;
server {
listen [my ip, hidden for security]:443 ssl;
ssl_certificate /opt/psa/var/certificates/certWLTI39G;
ssl_certificate_key /opt/psa/var/certificates/certWLTI39G;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass https://[my ip, hidden for security]:7081;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
另一项编辑: vhosts/housedoctors.com.conf
server {
listen [my ip, hidden for security]:80;
server_name housedoctors.com;
server_name www.housedoctors.com;
server_name ipv4.housedoctors.com;
client_max_body_size 128m;
root "/var/www/vhosts/housedoctors.com/httpdocs";
access_log "/var/www/vhosts/system/housedoctors.com/logs/proxy_access_log";
error_log "/var/www/vhosts/system/housedoctors.com/logs/proxy_error_log";
location / {
proxy_pass http://[my ip, hidden for security]:7080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Accel-Internal /internal-nginx-static-location;
access_log off;
}
location /internal-nginx-static-location/ {
alias /var/www/vhosts/housedoctors.com/httpdocs/;
add_header X-Powered-By PleskLin;
internal;
}
答案1
搜索包含该单词的行,rewrite
并用 将其注释掉#
。如果您已将其全部注释掉,但仍然被重定向,请检查重定向是否可能缓存在您的浏览器中。