Ruby on rails nginx作为domain.com访问subdomain.domain.com
我是Ruby on rails nginx作为domain.com访问subdomain.domain.com,ruby-on-rails,nginx,dns,http-redirect,Ruby On Rails,Nginx,Dns,Http Redirect,我是nginx系统的新手,之前,我通过subdomain.domain.com(无端口号)通过的帮助访问了subdomain.domain.com:3000 我发现难以实现以下目标: 我想通过domain.com访问运行在subdomain.domain.com中的Rails服务器。i、 e 当有人在浏览器中点击urldomain.com时,它应该充当subdomain.domain.com,但url不应该在浏览器中更改它 有人能帮我吗?我怎样才能做到 我已经注释掉了/etc/nginx/sit
nginx
系统的新手,之前,我通过subdomain.domain.com
(无端口号)通过的帮助访问了subdomain.domain.com:3000
我发现难以实现以下目标:
我想通过domain.com
访问运行在subdomain.domain.com
中的Rails服务器。i、 e当有人在浏览器中点击url
domain.com
时,它应该充当subdomain.domain.com
,但url不应该在浏览器中更改它
有人能帮我吗?我怎样才能做到
我已经注释掉了/etc/nginx/sites enabled/default中的默认设置,并创建了我的
/etc/nginx/sites enabled/myblog
中的自身设置为:
upstream my-app-cluster
{
server blog.budhram.com:3000;
}
server
{
listen 80;
server_name budhram.com;
# above not working but if used blog.budhram.com then working but not expected
# rails app public folder path
root /home/ubuntu/myblog/public;
# rails app log file path
access_log /home/ubuntu/myblog/log/development.log;
location / {
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_redirect off;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
proxy_pass http://my-app-cluster;
break;
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
您可以为代理设置所需的主机,url不应在浏览器中更改,但这可以更改代理站点上基于主机名的链接:
proxy_set_header Host subdomain.domain.com;
这个问题看起来更清楚了一点,需要添加nginx.conf
文件。@RobertChristopher使用我的nginx配置文件进行了更新。