Welcome! Log In Create A New Profile

Advanced

Nginx to server secure and not secure traffic

October 01, 2012 12:22PM
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 :
1. Does Nginx always picks the first server from the config ... irrespective of what client has requested and passes to proxy (php-fpm)?

2. 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.
Subject Author Posted

Nginx to server secure and not secure traffic

hsrmmr October 01, 2012 12:22PM

Re: Nginx to server secure and not secure traffic

Priority1 October 01, 2012 03:33PM

Re: Nginx to server secure and not secure traffic

hsrmmr October 02, 2012 12:30AM

Re: Nginx to server secure and not secure traffic

hsrmmr October 02, 2012 01:03AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 125
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready