1

我将 nginx 设置为 Thin Rails 应用服务器的反向代理。

server {
    listen 82;
    server_name www.hamburgers.com;
    root /var/user_cases/user_00001/user_case_11/public;
    location ~\.* {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header Host $host;
    }
}

一些页面打开,请参阅/var/log/nginx/access.log

127.0.0.1 - - [28/May/2012:18:33:53 +0400] "GET /assets/e.png HTTP/1.1" 304 0 "http://www.hamburgers.com:82/user_session/new" "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0"
127.0.0.1 - - [28/May/2012:18:34:01 +0400] "POST /user_session HTTP/1.1" 302 113 "http://www.hamburgers.com:82/user_session/new" "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:12.0) Gecko/20100101 Firefox/12.0"

但有些人在这样的记录中失败了/var/log/nginx/error.log

2012/05/28 18:34:03 [error] 5710#0: *117 open() "/var/www/nginx-default/user_cases" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /user_cases HTTP/1.1", host: "www.hamburgers.com", referrer: "http://www.hamburgers.com:82/user_session/new"

我想 nginx 出于某种原因使用/var/www/nginx-default而不是www.humburgers.com用于某些页面。我不知道为什么。

我该如何解决?

4

1 回答 1

3

找到解决方案。我应该使用

proxy_set_header Host $http_host;

代替

proxy_set_header Host $host;
于 2012-05-29T10:05:17.327 回答