We have secure and no secure domains for our website e.g.
secure.xyz.com
and xyz.com
I used following like to make single server handle both port 80 and 443
traffic.
http://nginx.org/en/docs/http/configuring_https_servers.html#single_http_https_server
server {
listen 80;
listen 443 ssl;
server_name secure.xyz.com xyz.com;
…
ssl_certificate secure.xyz.com.crt;
ssl_certificate_key secure.xyz.com.key;
…
}
Every thing works fine except that $_SERVER variables ‘SERVER_NAME’ is
set
to ‘secure.xyz.com’ .
My question is :
-
Does Nginx always picks the first server from the config …
irrespective
of what client has requested and passes to proxy (php-fpm)? -
We have a lot of rules, so if we create two separate server (as per
following) do I need to copy the rules in both places? It there any
maintainable way, like ‘include /common_rules.conf’?
server {
listen 443;
server_name secure.xyz.com;
ssl on;
ssl_certificate secure.xyz.com.crt;
…
include common_rules.conf; ===>???
}
server {
listen 80;
server_name xyz.com;
…
include common_rules.conf; ===>???
}
Any help is highly appreciated.
Posted at Nginx Forum: