Settings up SSL and non SSL Nginx sites to play nice together
I learned the hard way recently the importance of setting additional Nginx server configurations when hosting both SSL and Non-SSL sites on the same machine.
When I created a new server with an SSL connection and did not set a connection reset for the other sites that were not using SSL I found Google and other search engines were showing the wrong URL in my search results.
It took almost two weeks for the fix to propagate to all the search engines after I fixed it so don’t make the same mistake I did.
Make sure to create Nginx servers for HTTPS and HTTP for each website the machine will be hosting.
I made sure that the default configuration (IP without the domain or unknown server name would just reset the connection and not try to load another site. I also made sure that I forced SSL on sites that had it by redirecting users if they weren’t using SSL.
On sites that don’t use SSL I made a server running on SSL with the correct name that would reset the connection. I could possibly redirect the user back to an HTTP connection, but I don’t think it is necessary and have not tried it myself to make sure that it works.
- HTTP Server IP connection reset (444)
- HTTPS Server IP connection reset (444)
http://example.comredirection to https