使用unicorn配置子域nginx
我在linode中使用nginx+unicorn 这是我的nginx.conf使用unicorn配置子域nginx,nginx,unicorn,Nginx,Unicorn,我在linode中使用nginx+unicorn 这是我的nginx.conf upstream unicorn { server unix:/tmp/unicorn.mydomain.sock fail_timeout=0; } server { listen 80 default; server_name mydomain.com; keepalive_timeout 5; root /home/hyperrjas/mydomain.com/current/publ
upstream unicorn {
server unix:/tmp/unicorn.mydomain.sock fail_timeout=0;
}
server {
listen 80 default;
server_name mydomain.com;
keepalive_timeout 5;
root /home/hyperrjas/mydomain.com/current/public;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# this is required for HTTPS:
# proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
location ~ ^/(assets)/ {
root /home/hyperrjas/mydomain.com/current/public;
gzip_static on; # to serve pre-gzipped version
expires max;
add_header Cache-Control public;
}
error_page 500 502 503 504 /500.html;
}
我想添加4个子域:
imagescdn1.mydomain.com
imagescdn2.mydomain.com
imagescdn3.mydomain.com
imagescdn4.mydomain.com
如何执行此操作?您应该使用regex for server\u name指令,例如:
server {
server_name mydomain.com ~^imagescdn\d+\.mydomain\.com$;
}
有关详细信息,请参阅原始文档。是的,您可以将www.mydomain.com添加到列表中:服务器名称mydomain.com www.mydomain.com~^imagescdn\d+\.mydomain\.com$;