【发布时间】:2015-09-01 04:32:26
【问题描述】:
我正在尝试将 nginx 服务器配置为充当节点应用程序的代理。我想要的是让 nginx 提供的所有静态文件和所有其他路径都转发到 Node.js 应用程序(包括 / 路径)。
我看过以下问题/答案:How to serve all existing static files directly with NGINX, but proxy the rest to a backend server.
按照指示,我已将我的站点配置配置如下:
server {
server_name subdom.domain.com;
listen 80;
location / {
root /var/www/application/public_html;
try_files $uri $uri/ @application;
}
location @application {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:3000;
}
}
但是,当浏览 subdom.domain.com/ 时,我收到 403 Forbidden。我猜这是因为 nginx 找不到默认文档,但我希望将默认文档发送到代理,知道该怎么做吗?
【问题讨论】: