【问题标题】:Configure Nginx to use several directories配置 Nginx 使用多个目录
【发布时间】:2016-04-27 07:07:00
【问题描述】:

这里有 config nginx 指的是http://example.com/sellers 必须从文件夹 /data/sellers 给服务器 在另一种情况下 - 文件夹 /data/customers

Nginx 配置:

    server {
    listen       80;
    server_name  localhost;
    index index.html index.htm home.html;

    location /sellers {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        rewrite ^/sellers/?(.*) /$1 break;
        root   /data/sellers;
    }

    location / {
        root   /data/customers;
    }
}

一切正常,但并不完全正确:当访问服务器时,卖家以某种方式使用文件夹 /data/customers/index.html 中的 index.html 以及文件夹 /data/sellers 的所有其余部分(这是正确的) 有什么问题?为什么 nginx 使用了错误的 index.html 文件,尽管乔治亚州的所有其他地方都是正确的?

【问题讨论】:

  • 我投票结束这个问题,因为它不是英文的。
  • 对不起。我现在就翻译
  • 我认为在俄罗斯社区写作。再次抱歉。

标签: html ubuntu nginx config


【解决方案1】:

回答

server {
  listen       80;
  server_name  localhost;
  index index.html index.htm home.html;
  root /data/customers;

  location /sellers {
    alias /data/sellers;
  }
}

【讨论】:

    猜你喜欢
    • 2017-05-28
    • 2015-05-21
    • 2013-09-05
    • 2018-05-21
    • 2016-11-29
    • 1970-01-01
    • 1970-01-01
    • 2016-11-03
    • 1970-01-01
    相关资源
    最近更新 更多