64
我有nginx作爲apache的反向代理。我現在需要添加一個新的子域 ,它將提供來自另一個目錄的文件,但同時我希望我的默認主機的所有位置和proxy_pass指令也適用於子域。nginx子域配置
我知道,如果我從默認主機複製的規則到新的子,將工作,但那裏的子域名的方式來繼承規則? 下面是一個示例配置
server {
listen 80;
server_name www.somesite.com;
access_log logs/access.log;
error_log logs/error.log error;
location /mvc {
proxy_pass http://localhost:8080/mvc;
}
location /assets {
alias /var/www/html/assets;
expires max;
}
... a lot more locations
}
server {
listen 80;
server_name subdomain.somesite.com;
location/{
root /var/www/some_dir;
index index.html index.htm;
}
}
感謝
好主意。我是否需要將指令包裝在另一個指令下,就像我所做的那樣,當我重新啓動nginx時,nginx會抱怨:nginx:[emerg]「location」指令在這裏是不允許的 – Thomas 2012-03-28 11:36:01
我正在編輯我的答案而不是此評論:) – 2012-03-28 15:13:31
那是我試過的,我得到了我提到的錯誤。你有沒有嘗試過,它的工作? – Thomas 2012-03-29 15:04:56