added rewrite for 'www'-prefixed requests
This commit is contained in:
parent
93ee4acb23
commit
ba13e8bb5d
2 changed files with 18 additions and 0 deletions
|
@ -1,5 +1,13 @@
|
|||
 
|
||||
|
||||
##Modifications
|
||||
|
||||
To make Jason's nginx-proxy work for me, I changed:
|
||||
|
||||
- added rewrite of 'www'-prefixed domains to 301 without prefix for both https and http protocol
|
||||
|
||||
##Original
|
||||
|
||||
nginx-proxy sets up a container running nginx and [docker-gen][1]. docker-gen generates reverse proxy configs for nginx and reloads nginx when containers are started and stopped.
|
||||
|
||||
See [Automated Nginx Reverse Proxy for Docker][2] for why you might want to use this.
|
||||
|
|
10
nginx.tmpl
10
nginx.tmpl
|
@ -83,6 +83,11 @@ upstream {{ $host }} {
|
|||
|
||||
{{ if (and (ne $cert "") (exists (printf "/etc/nginx/certs/%s.crt" $cert)) (exists (printf "/etc/nginx/certs/%s.key" $cert))) }}
|
||||
|
||||
server {
|
||||
server_name www.{{ $host }};
|
||||
rewrite ^(.*) https://{{ $host }}$1 permanent;
|
||||
}
|
||||
|
||||
server {
|
||||
server_name {{ $host }};
|
||||
rewrite ^(.*) https://{{ $host }}$1 permanent;
|
||||
|
@ -114,6 +119,11 @@ server {
|
|||
}
|
||||
{{ else }}
|
||||
|
||||
server {
|
||||
server_name www.{{ $host }};
|
||||
rewrite ^(.*) http://{{ $host }}$1 permanent;
|
||||
}
|
||||
|
||||
server {
|
||||
server_name {{ $host }};
|
||||
|
||||
|
|
Loading…
Reference in a new issue