我在运行Ubuntu 12.04的新服务器上设置Nginx.这是我到目前为止所做的:
>已安装的Nginx:
aptitude -y install Nginx
>删除了默认的vhost配置:
rm /etc/Nginx/sites-enabled/*
>添加了我自己的vhost配置:
mv myapp.conf /etc/Nginx/sites-enabled/
>开始使用Nginx:
service Nginx start
vhost文件看起来像这样:
upstream unicorn_server {
server unix:/tmp/APP_NAME.sock fail_timeout=0;
}
server {
listen 80 default deferred;
client_max_body_size 4G;
server_name _;
keepalive_timeout 5;
access_log /var/log/Nginx/APP_NAME.access.log;
root /var/www/APP_NAME/current/public;
# auth
try_files $uri/index.html $uri.html $uri @app;
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn_server;
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /var/www/APP_NAME/current/public;
}
}
我可以确认Nginx正在运行:
service Nginx status
* Nginx is running
但是,我似乎无法访问它:
curl 123.456.789.0 # example IP
curl: (7) couldn't connect to host
我还没有启动unicorn服务器,但这应该不是问题.如果Unicorn没有运行,我希望看到502错误.错误或访问日志中没有输出.我应该采取哪些措施来解决问题?
最佳答案
原文链接:https://www.f2er.com/nginx/435407.html