Configuring multiple domain in nginx in one file
Posted
by
user22695
on Server Fault
See other posts from Server Fault
or by user22695
Published on 2014-08-22T14:06:53Z
Indexed on
2014/08/23
4:22 UTC
Read the original article
Hit count: 413
nginx
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 ...
}
© Server Fault or respective owner