Using nginx's error_page
directive we can support SSL over both :80
and :443
Some intrusive firewalls, ISPs, companies, and ``Anti-virus'' programs attempt to intercept SSL connections on :443
. Some of these programs even offer their own certificate, in order to perform MiTM attacks. In more extreme cases, connections may be entirely blocked on :443
.
By allowing SSL connections on :80
, users with these threats may still access the server securely.
Using nginx's
error_page
directive, and nginx's (non-standard)
HTTP 497 error
we can (internally or externally) redirect requests based on whether or not SSL was used.
See the example configuration directives in example.nginxconf
See a live server at https://denpa.moe/
(The content on the page is irrelevant to the demonstration)
Some example URLs to try out:
http://denpa.moe:80/
– should redirect to SSL on:443
http://denpa.moe:443/
– should redirect to SSL on:443
https://denpa.moe:80/
– should load over SSL on:80
https://denpa.moe:443/
– should load over SSL on:443
Probably not.
While I use this setup on my hobby server as a ``kind of neat feature'', I wouldn't reccomend it for production-use because it isn't an officially supported feature.