Created
November 24, 2014 18:18
-
-
Save brycied00d/564dbadead55dd3b8414 to your computer and use it in GitHub Desktop.
nginx redirect to the FQDN with an alternative port
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; ## listen for ipv4; this line is default and implied | |
listen [::]:80 default_server ipv6only=on; ## listen for ipv6 | |
server_name localhost; # A sane default, nobody cares | |
# The actual logic | |
set $this_host $host; | |
if ($host !~* "\.fqdn\.com$") { | |
#rewrite ^ https://$host.fqdn.com:8006$request_uri? permanent; | |
set $this_host "$host.fqdn.com"; | |
} | |
rewrite ^ https://$this_host:8006$request_uri? permanent; | |
} | |
server { | |
listen 443 default_server; | |
listen [::]:443 default_server ipv6only=on; | |
server_name localhost; # A sane default, nobody cares | |
ssl on; | |
ssl_certificate /path/to/the.pem; | |
ssl_certificate_key /path/to/the.key; | |
ssl_session_timeout 1m; | |
ssl_protocols SSLv3 TLSv1; | |
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP; | |
ssl_prefer_server_ciphers on; | |
# The actual logic | |
set $this_host $host; | |
if ($host !~* "\.fqdn\.com$") { | |
#rewrite ^ https://$host.fqdn.com:8006$request_uri? permanent; | |
set $this_host "$host.fqdn.com"; | |
} | |
rewrite ^ https://$this_host:8006$request_uri? permanent; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment