added rewrite for 'www'-prefixed requests

This commit is contained in:
mko 2015-02-10 22:52:04 +01:00
parent 93ee4acb23
commit ba13e8bb5d
2 changed files with 18 additions and 0 deletions

View file

@ -1,5 +1,13 @@
![nginx 1.7.8](https://img.shields.io/badge/nginx-1.7.8-brightgreen.svg) ![License MIT](https://img.shields.io/badge/license-MIT-blue.svg)
##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.

View file

@ -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 }};