duanshaiduhao2471 2017-03-29 06:24
浏览 428
已采纳

没有proxy_set_header主机,无法访问wordpress前端页面

I use nginx as reverse proxy for apache wordpress site. But I cannot access word.com frontend page if I comment out the proxy_set_header part, it just redirect to 127.0.0.1 in my brower. Who can explain it for me? Nginx settings:

server {
    listen 80 default_server;
    server_name word.com
    charset utf-8;
    index index.htm index.html;
    access_log /var/log/nginx/word-access.log main;
    error_log /var/log/nginx/word-error.log;

    location / {
        proxy_pass http://127.0.0.1:8080;
    }

    proxy_set_header        Host $host;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
}
  • 写回答

1条回答 默认 最新

  • dongshuxi3105 2017-03-29 09:55
    关注

    In the absence of a proxy_set_header directive, nginx will set the proxied Host header to 127.0.0.0:8080.

    Apache will see this hostname and use it when constructing certain response to the browser (such as a redirect).

    It is usual to specify proxy_set_header Host $host;. The default value is only useful in limited cases, such as contacting remote resources.

    See this document for more.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?