我的Nginx反向代理配置遇到了这样的情况。我的发行版是Ubuntu 14.04
我有一个域,我们将其命名为foo.bar.net,我希望/grafana端点重定向到我的grafana服务器(localhost:3000),/sentry端点重定向到我的哨兵服务器(localhost:9000),最后,/private端点重定向到我的django服务器(localhost:8001)。在django和nginx之间的调谐中使用了gunicorn。
这是我尝试过的:
server {
# listen on port 80
listen 80 default_server;
# for requests to these domains
server_name foo.bar.net;
location /sentry {
# keep logs in these files
access_log /var/log/nginx/sentry.access.log;
error_log /var/log/nginx/sentry.error.log;
# You need this to allow users to upload large files
# See http://wiki.nginx.org/HttpCoreModule#client_max_body_size
# I'm not sure where it goes, so I put it in twice. It works.
client_max_body_size 0;
proxy_pass http://localhost:9000;
proxy_redirect off;
proxy_read_timeout 5m;
allow 0.0.0.0;
# make sure these HTTP headers are set properly
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /grafana {
proxy_pass http://localhost:3000;
proxy_redirect off;
proxy_read_timeout 5m;
allow 0.0.0.0;
# make sure these HTTP headers are set properly
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /private {
proxy_pass http://127.0.0.1:8001;
}
location /private/static/ {
autoindex on;
alias /home/user/folder/private/static/;
}
}服务器甚至不能正确启动,配置没有加载。
如果可能,我还希望/ path重定向到私有端点。
此外,我甚至不确定将此配置放在哪里(sites-available/??)
有人能帮我吗?
非常感谢,
发布于 2015-09-17 22:00:24
有一些缺少分号和其他语法错误。请查看nginx主错误日志了解详细信息,并逐一修复。
配置文件的位置取决于您的发行版。对于其中一些文件,它应该是sites available directory and symlink to them file in sites enabled directory以便快速启用和禁用站点,如果您没有sites available和sites enabled目录,则应将其放入发行版的conf.d目录中。
https://stackoverflow.com/questions/32631952
复制相似问题