fix redirect https : show port only if not 443

pull/2/merge 1.3.6
Emilien Mantel 2017-04-13 15:16:53 +02:00
parent f1af8991fd
commit a60e81cc1f
2 changed files with 9 additions and 8 deletions

View File

@ -28,7 +28,7 @@ server {
listen {{ port }}{% if port | int in __http_proxy_protocol_port %} proxy_protocol{% endif %}; listen {{ port }}{% if port | int in __http_proxy_protocol_port %} proxy_protocol{% endif %};
{% endfor %} {% endfor %}
server_name {{ name }}; server_name {{ name }};
return 301 https://{{ name }}{% if '443' not in __listen_ssl %}:{{ __listen_ssl[0] }}{% endif %}$request_uri; return 301 https://{{ name }}{% if '443' not in __listen_ssl and 443 not in __listen_ssl %}:{{ __listen_ssl[0] }}{% endif %}$request_uri;
} }
{% endmacro %} {% endmacro %}

View File

@ -215,6 +215,7 @@
- name: - name:
- 'test-ssl-redirect-many.local' - 'test-ssl-redirect-many.local'
- 'test-ssl-redirect-many2.local' - 'test-ssl-redirect-many2.local'
listen_ssl: [8443]
proto: ['https'] proto: ['https']
template: '_base' template: '_base'
ssl_name: 'test-ssl.local' ssl_name: 'test-ssl.local'
@ -381,16 +382,16 @@
- 'test-ssl-predeployed.local' - 'test-ssl-predeployed.local'
- 'test-ssl.local' - 'test-ssl.local'
- name: -- VERIFY SSL REDIRECT -- - name: -- VERIFY SSL REDIRECT --
command: "curl -v --insecure -H 'Host: {{ item }}' http://127.0.0.1/" command: "curl -v -H 'Host: {{ item.name }}' http://127.0.0.1/"
changed_when: false changed_when: false
register: sslredirok register: sslredirok
failed_when: > failed_when: "'< Location: https://{{ item.name }}{{ ':' + item.port if item.port is defined else '' }}/' not in sslredirok.stderr"
sslredirok.stderr.find('< Location') == -1 and
sslredirok.stderr.find('https://{{ item }}/') == -1
with_items: with_items:
- 'test-ssl-redirect.local' - name: 'test-ssl-redirect.local'
- 'test-ssl-redirect-many.local' - name: 'test-ssl-redirect-many.local'
- 'test-ssl-redirect-many2.local' port: '8443'
- name: 'test-ssl-redirect-many2.local'
port: '8443'
# -------------------------------- # --------------------------------
# Default vhosts # Default vhosts