我仍然是配置nginx的新手。
在一个文件中配置多个域,并且它们基本上共享相同的配置,这是正确的吗?
例如,我想配置两个基于一个应用程序的域,一个域需要基本的auth,另一个域不需要。
我想做这样的事,但我认为这是行不通的:
网站-启用/mysite
server {
listen 127.0.0.1:80 default_server;
server_name www.mysite.com;
include sharedconf.conf;
}
server {
listen 127.0.0.1:80;
server_name www.mysite.co.jp;
auth_basic "restricted";
auth_basic_user_file /etc/nginx.htpasswd;
include sharedconf.conf;
}
sharedconf.conf
location / {
proxy_pass_header Server;
#... bunch of config line ...
}
发布于 2014-08-22 18:20:48
是的,这个很好。
我假设您使用的是Debian或Debian派生的Linux发行版。那么您就不能将sharedconf.conf
放入/etc/nginx/sites-enabled
或/etc/nginx/conf.d
中,因为这些目录中的文件都包含在Debian上的主nginx.conf
中。
https://serverfault.com/questions/623327
复制相似问题