Configuring multiple domain in nginx in one file
- by user22695
I am still newbie configuring nginx.
Is it posibble to configure multiple domain in one file and they share mostly the same config?
For example I want to configure two domains that based from one app and
one domain need basic auth, the other doesn't.
I would like to do something like this,
but I think this does not work:
sites-enabled/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 ...
}