ubuntu - Nginx redirect http subdomains to https -
i have 1 domain 3 subdomains:
- example.com (main domain) - api.example.com - blog.example.com - support.example.com (just cname point zendesk)
and have 3 configuration on nginx:
api
# http server server { listen 80; server_name api.example.com; return 301 https://api.example.com$request_uri; } # https server server { ssl on; listen 443; server_name api.example.com; ssl_certificate apicert.crt; ssl_certificate_key apicert.key; #root configuration..... }
blog
server { listen 80; server_name blog.example.com; root /var/www/blog; index index.php index.html index.htm;
site/main domain
server { listen 80; listen 443 ssl; server_name www.example.com; return 301 https://example.com$request_uri; location ~ \.(php|html)$ { deny all; } } server { listen 80; server_name example.com; return 301 https://example.com$request_uri; location ~ \.(php|html)$ { deny all; } } server { ssl on; listen 443 ssl; ssl_certificate mycert.crt; ssl_certificate_key mycert.key; server_name example.com; root /var/www/frontend; ..... }
my problem:
- the subdomain api.example ok!
- the main domain http://example.com , https://example.com ok!
- if try access main domain www on http browser redirect correct https://example.com. when try access main domain www , https, https://www.example.com, browser try access ssl cert api.
- and after try access main domain , redirect https other subdomains doesn't have https redirect https , show error, because tried use ssl cert api.
- example: if try access http://blog.exemple.com, firefox redirect https://blog.example.com , show ssl error.
- this video showing this problem
- the domain online, can test on http://blog.alooga.com.br, http://alooga.com.br
your web server setup strict-transport-security max-age=16070400; includesubdomains
.
this tell web browser request domain using https only. if want subdomain blog
accessed through insecure http, need remove includesubdomains
http strict transport security (hsts) , use different browser (or clear firefox).
https://www.ssllabs.com/ssltest/analyze.html?d=alooga.com.br
Comments
Post a Comment