【发布时间】:2014-07-22 21:53:05
【问题描述】:
我开发了 rails 应用程序,它在域 mpm.head-system.com 上工作
在我的 VPS 上,该应用位于 /home/mobile_market path。
这是 nginx.conf:
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events { worker_connections 1024; }
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
gzip_types text/plain text/xml text/css text/comma-separated-values;
upstream app_server {
server 127.0.0.1:8080 fail_timeout=0;
}
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
这是启用站点/默认配置:
server {
listen 80;
root /home/mobile_market/public/;
server_name mpm.head-system.com;
index index.htm index.html;
location / {
try_files $uri/index.html $uri.html $uri @app;
}
location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|flv|mpeg|avi)$ {
try_files $uri @app;
}
location @app {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}
一切正常,现在我在同一个 VPS 上有了一个新的 rails 应用程序(redmine)。
现在我在同一个 VPS 上设置 redmine,它可以在 3000 端口上运行 - mpm.head-system.com:3000
如何更改 nginx.conf 以在子域上设置我的 redmine 应用程序 - redmine.head-system.com ? 如何连接在其他端口上运行的应用程序作为子域? (因为在 /etc/hosts 我只能设置没有端口的 IP)。 我知道我需要使用 proxy_pass 和虚拟主机,但我不知道如何:(
请帮忙...
【问题讨论】:
标签: ruby-on-rails nginx subdomain config proxypass