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 %};
{% endfor %}
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 %}

View File

@ -215,6 +215,7 @@
- name:
- 'test-ssl-redirect-many.local'
- 'test-ssl-redirect-many2.local'
listen_ssl: [8443]
proto: ['https']
template: '_base'
ssl_name: 'test-ssl.local'
@ -381,16 +382,16 @@
- 'test-ssl-predeployed.local'
- 'test-ssl.local'
- 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
register: sslredirok
failed_when: >
sslredirok.stderr.find('< Location') == -1 and
sslredirok.stderr.find('https://{{ item }}/') == -1
failed_when: "'< Location: https://{{ item.name }}{{ ':' + item.port if item.port is defined else '' }}/' not in sslredirok.stderr"
with_items:
- 'test-ssl-redirect.local'
- 'test-ssl-redirect-many.local'
- 'test-ssl-redirect-many2.local'
- name: 'test-ssl-redirect.local'
- name: 'test-ssl-redirect-many.local'
port: '8443'
- name: 'test-ssl-redirect-many2.local'
port: '8443'
# --------------------------------
# Default vhosts