apache前端+nginx后端,nginx如何rewrite正确的地址
程序员文章站
2024-01-03 10:29:10
...
运行环境
centos 6.5 + lanmp
apache作后端,nginx作前端
软件: wordpress
centos 6.5 + lanmp
apache作后端,nginx作前端
软件: wordpress
nginx虚拟主机配置如下:
server {
listen 80;
server_name xxx.com;
root /var/www/xxx/html;
index index.html index.htm index.php;
#这句是wordpress的rewriter语句
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
#php文件转发给apache处理
location ~ \.(php)?$ {
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_pass http://127.0.0.1:8080;
}
}
如果是在lnmp环境下,下面的rewrite语句是没问题的
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
但在lanmp环境下,点击地址后,地址栏的地址是变了,显示的页面却是首页。不知道是哪里错了?
固定链接样式:http://xxx.com/xxx/
回复内容:
运行环境
centos 6.5 + lanmp
apache作后端,nginx作前端
软件: wordpress
nginx虚拟主机配置如下:
server {
listen 80;
server_name xxx.com;
root /var/www/xxx/html;
index index.html index.htm index.php;
#这句是wordpress的rewriter语句
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
#php文件转发给apache处理
location ~ \.(php)?$ {
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_pass http://127.0.0.1:8080;
}
}
如果是在lnmp环境下,下面的rewrite语句是没问题的
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
但在lanmp环境下,点击地址后,地址栏的地址是变了,显示的页面却是首页。不知道是哪里错了?
固定链接样式:http://xxx.com/xxx/
location / {
try_files $uri @apache ;
}
location @apache {
internal;
proxy_pass http://127.0.0.1:8080;
}