我最近使用 Phusion Passenger 设置了 Nginx,旨在将 rails 应用程序部署到 sub-uri。rails 应用程序根据需要部署,但是,当我导航到 projectvisionapps.com 时,我注意到 nginx 将我路由到 projectvisionapps.com/index.html/,它会抛出 404。如果我手动输入 projectvisionapps.com/index.html , nginx 提供正确的页面。
有什么线索或建议吗?
检查 nginx 错误日志,我看到:
2012/10/06 19:23:05 [error] 20782#0: *21 "/var/www/vhosts/projectvisionapps.com/httpdocs/index.html/index.html" is not found (20: Not a directory), client: 50.1.57.140, server: , request: "GET /index.html/ HTTP/1.1", host: "www.projectvisionapps.com"
我的 nginx.conf 如下:
#user nobody;
worker_processes 1;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
index index.html;
passenger_root /home/samudzi/.rvm/gems/ruby-1.9.3-p194@global/gems/passenger-3.0.17;
passenger_ruby /home/samudzi/.rvm/wrappers/ruby-1.9.3-p194/ruby;
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
include /opt/nginx/conf/conf.d/*.conf;
}
我包含的 .conf 文件是:
server {
listen 74.208.46.76:80;
server_name projectvisionapps.com;
#root /var/www/vhosts/projectvisionapps.com/httpdocs;
#try_files $uri.html $uri $uri/ @notfound;
location / {
index index.html;
root /var/www/vhosts/projectvisionapps.com/httpdocs;
try_files $uri $uri/ /index.html;
}
}
对于 rails 应用程序(完美运行)
server {
listen 74.208.46.76:80;
#server_name projectvisionapps.com;
root /var/www/vhosts/projectvisionapps.com/httpdocs;
passenger_enabled on;
passenger_base_uri /dev;
rails_spawn_method smart;
rails_env development;
gzip on;
}
感谢您的任何建议或建议!