我正在使用OSX localhost上的Nginx + Passenger测试反向代理
我的nginx.conf就像:
一样简单 #user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://localhost:8081/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
}
location /simpleapp {
proxy_pass http://localhost:3000/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
}
}
server {
listen 8081;
server_name bayoo.website.local;
root /Users/bayoo/Sites;
index index.html index.htm;
}
server {
listen 3000;
server_name simpleapp.local;
root /Users/bayoo/Developpement/RAILS-41/simpleapp/public;
passenger_enabled on;
}
}
127.0.0.1 simpleapp.local已添加到/ etc / hosts
中在浏览器中尝试网址时: // localhost(proxy to => bayoo.website.local)好的 //bayoo.website.local好的 但 // localhost / simpleapp => 403 Forbidden,error.log中没有信息 和 //simpleapp.local不显示任何内容,似乎被锁定
我的nginx配置有什么问题?我已经单独测试了rails服务器:
server {
listen 3000;
server_name simpleapp.local;
root /Users/bayoo/Developpement/RAILS-41/simpleapp/public;
passenger_enabled on;
}
它运行良好