5

我有

server {
    listen 80;
    server_name domain1 domain2 domain3

    location / {
        proxy_pass http://127.0.0.1:8088;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;

        proxy_connect_timeout   120;
        proxy_send_timeout      120;
        proxy_read_timeout      180;
    }
}

server {
     listen domainX:80;
     server_name domainX www.domainX

     location / {
            proxy_pass http://127.0.0.1:8088;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;

            proxy_connect_timeout   120;
            proxy_send_timeout      120;
            proxy_read_timeout      180;
    }

    location ~* \.(jpeg|jpg|gif|png|ico|bmp|swf|css|js)$ {
            root domainXStaticRoot
    }

    # other options for domainX only
}

对于来自第一个服务器块的域,nginx 仅返回根页面:

http://domain1 -> returns root page for domain1
http://domain1/style.css -> nginx trying return according location from server block two eg domainXStaticRoot/style.css

如果修改监听80;听 domain1:80; 然后对于 domain1 一切正常,但我没有找到如何在 listen 指令中编写多个域。

我的错误在哪里?

4

0 回答 0