您好,这是我第一次将Rails应用程序部署到ubuntu服务器,因此在配置nginx并在特定IP上获得"welcome to nginx page"
之后,当我启动Rails应用程序时,必须在IP中输入端口例如165.217.84.11:3000
的地址以访问Rails,这样当我仅运行此IP 165.217.84.11
答案 0 :(得分:1)
您可以这样设置从80端口(默认为默认)到3000端口的重定向:
worker_processes 1;
events { worker_connections 1024; }
http {
client_max_body_size 10m;
sendfile on;
upstream rails {
server 165.217.84.11:3000;
}
server {
listen 80;
location / {
proxy_pass http://rails-app;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Ssl off;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Host $server_name;
}
}
}
因此,当您在浏览器中访问165.217.84.11时,您应该会看到rails项目。
答案 1 :(得分:0)