Apache Front end +nginx Backend, nginx How to rewrite the correct address

Source: Internet
Author: User
Operating Environment
CentOS 6.5 + LANMP
Apache as back end, nginx as front end
Software: WordPress

Nginx Virtual Host configuration is as follows:
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;}

}

If it is in the LNMP environment, the following rewrite statement is no problem
Location/{
Try_files $uri $uri//index.php?q= $uri & $args;
}

However, in the LANMP environment, after clicking on the address, the address bar is changed, the page displayed is the homepage. Do not know where is wrong?

Fixed link style: http://xxx.com/xxx/

Reply content:

Operating Environment
CentOS 6.5 + LANMP
Apache as back end, nginx as front end
Software: WordPress

Nginx Virtual Host configuration is as follows:
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;}

}

If it is in the LNMP environment, the following rewrite statement is no problem
Location/{
Try_files $uri $uri//index.php?q= $uri & $args;
}

However, in the LANMP environment, after clicking on the address, the address bar is changed, the page displayed is the homepage. Do not know where is wrong?

Fixed link style: http://xxx.com/xxx/

location / {    try_files $uri @apache ;}location @apache {    internal;    proxy_pass http://127.0.0.1:8080;}
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.