【发布时间】:2018-06-15 15:26:18
【问题描述】:
我正在 Ubuntu 服务器上开发一个 Ruby on Rails 项目。每当我尝试访问该应用程序时,总是会收到以下信息:
欢迎使用 nginx!
如果您看到此页面,则 nginx Web 服务器已成功安装并正在运行。需要进一步配置。
这是我在“sites_enabled”目录中的代码:
pstream unicorn_site {
server unix:/tmp/unicorn.site.sock fail_timeout=0;
}
server {
listen 80;
client_max_body_size 4G;
keepalive_timeout 10;
error_page 500 502 504 /500.html;
error_page 503 @503;
server_name http://[ip_address];
root /data/site/current/public;
try_files $uri/index.html $uri @unicorn_site;
location @unicorn_site {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn_site;
# limit_req zone=one;
access_log /var/log/nginx/site.access.log;
error_log /var/log/nginx/site.error.log;
}
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
location = /50x.html {
root html;
}
location = /404.html {
root html;
}
location @503 {
error_page 405 = /system/maintenance.html;
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html break;
}
rewrite ^(.*)$ /503.html break;
}
if ($request_method !~ ^(GET|HEAD|PUT|PATCH|POST|DELETE|OPTIONS)){
return 405;
}
if (-f $document_root/system/maintenance.html) {
return 503;
}
}
我不确定问题出在哪里,因为该应用似乎具备正常运行所需的一切。我可以提供任何人需要的代码的任何部分。非常感谢您的帮助。
编辑:当我尝试加载页面时,我也总是收到此错误:
2018/06/15 15:39:10 [警告] 15280#0:服务器名称“http://[ip_address]”在 /etc/nginx/sites-enabled/site:14 中有可疑符号
编辑 2:这里是 nginx.conf
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
【问题讨论】:
标签: ruby-on-rails ubuntu nginx unicorn