0
我是nginx
系統的新手,之前我通過this answer的幫助設法訪問了subdomain.domain.com:3000
到subdomain.domain.com
(沒有端口號)。nginx訪問subdomain.domain.com作爲domain.com
我發現在實現以下困難:
我要訪問我的Rails服務器subdomain.domain.com
通過domain.com
運行。即
當有人在瀏覽器中點擊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;
}
}
看起來更清晰一些,需要添加'nginx.conf'文件。 – 2014-09-20 11:12:41
@RobertChristopher更新了我的nginx配置文件。 – ram 2014-09-20 11:24:21