好吧。。我遇到了一个问题,在这个 nginx 配置中,每个页面都加载了完全相同的页面。正在加载的页面似乎是 index.php
不太清楚发生了什么?它应该从磁盘提供资源,并将 php 请求重定向到 index.php
我的 nginx 虚拟主机:
server {
listen 1.2.3.4:443 ssl;
server_name xxxxxxxxxx;
server_name xxxxxx;
server_name xxxxxxxx;
ssl_certificate /usr/local/psa/var/certificates/xxxx;
ssl_certificate_key /usr/local/psa/var/certificates/xxxx;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
client_max_body_size 128m;
add_header Bryan was_here;
root /var/www/vhosts/xxxx/httpdocs/;
disable_symlinks off;
location / {
try_files $uri $uri/ /index.php?$args;
access_log off;
}
#location = / {
#index index.php;
#}
# set a nice expire for assets
location ~* "^.+\.(jpe?g|gif|css|png|js|ico|pdf|zip|tar|t?gz|mp3|wav|swf)$" {
expires max;
add_header Cache-Control public;
}
# the downloader has its own index.php that needs to be used
location ~* ^(/downloader|/js|/404|/report)(.*) {
proxy_pass http://1.2.3.4: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;
}
location ~* \.php {
proxy_pass http://1.2.3.4: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;
}
location /internal-nginx-static-location/ {
alias /var/www/vhosts/xxxx/httpdocs/;
access_log /var/www/vhosts/xxxx/statistics/logs/proxy_access_ssl_log;
add_header X-Powered-By PleskLin;
internal;
}
}
server {
listen 1.2.3.4:443 ssl;
server_name webmail.xxxx;
ssl_certificate /usr/local/psa/var/certificates/xxxx;
ssl_certificate_key /usr/local/psa/var/certificates/xxxx;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
client_max_body_size 128m;
location / { # IPv6 isn't supported in proxy_pass yet.
proxy_pass https://1.2.3.4: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;
access_log /var/www/vhosts/xxxx/statistics/logs/webmail_access_ssl_log;
}
}
server {
listen 1.2.3.4:80;
server_name xxxx;
server_name xxxx;
server_name xxxx;
client_max_body_size 128m;
root /var/www/vhosts/xxxx/httpdocs/;
disable_symlinks off;
location / {
try_files $uri $uri/ /index.php?$args;
access_log off;
#proxy_pass https://1.2.3.4: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;
}
#location = / {
#index index.php;
#}
# set a nice expire for assets
location ~* "^.+\.(jpe?g|gif|css|png|js|ico|pdf|zip|tar|t?gz|mp3|wav|swf)$" {
expires max;
add_header Cache-Control public;
}
# the downloader has its own index.php that needs to be used
location ~* ^(/downloader|/js|/404|/report)(.*) {
proxy_pass http://1.2.3.4: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;
}
location ~* \.php {
proxy_pass http://1.2.3.4: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;
}
location /internal-nginx-static-location/ {
alias /var/www/vhosts/xxxx/httpdocs/;
access_log /var/www/vhosts/xxxx/statistics/logs/proxy_access_log;
internal;
}
}
server {
listen 1.2.3.4:80;
server_name webmail.xxxx;
client_max_body_size 128m;
location / { # IPv6 isn't supported in proxy_pass yet.
proxy_pass http://1.2.3.4: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;
access_log /var/www/vhosts/xxxx/statistics/logs/webmail_access_log;
}
}
/etc/nginx/nginx.conf:
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;
#autoindex off;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#tcp_nodelay on;
#gzip on;
#gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip on;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
server_tokens off;
include /etc/nginx/conf.d/*.conf;
}
答案1
我在这里猜测,但您的 try_files 参数在我看来是错误的。
尝试一下
/index.php?q=$uri&$args;
此外,我们可以有关于这个vhost的error.log吗?