【发布时间】:2016-07-10 10:03:09
【问题描述】:
我有两个应用程序的 nginx 配置:
1) Rails 应用程序
upstream app {
server unix:/home/deploy/railsapp/shared/tmp/sockets/puma.sock fail_timeout=0;
}
server {
listen 80;
server_name api.example.com;
root /home/deploy/railsapp/current/public;
try_files $uri/index.html $uri @app;
location / {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Connection '';
proxy_pass http://app;
}
location ~ ^/(assets|fonts|system)/|favicon.ico|robots.txt {
gzip_static on;
expires max;
add_header Cache-Control public;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
2) 静态 html/js 应用程序
server {
listen 81;
server_name client.example.com;
root /home/deploy/clientapp;
location / {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Connection '';
# proxy_pass http://app;
}
location ~ ^/(assets|fonts|system)/|favicon.ico|robots.txt {
gzip_static on;
expires max;
add_header Cache-Control public;
}
}
问题是两个地址api.example.com和api.example.com打开同一个应用程序(对于api.example.com)
【问题讨论】:
-
@PeterS 这只是一个没有原始地址的例子。两个地址都是子域
标签: ruby-on-rails ruby-on-rails-4 nginx puma