Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Wildcard certificate - force redirect http to https for specific domain

$
0
0
Hi all,
My environment : Centos 6.9 + rh-nginx18-nginx-1.8.1-1.el6.x86_64 .
I have wildcard certificate for domain *.mydomain.com , server accepts both http and https requests
[code]
server {
listen 192.168.0.19:80; # we serve both http and https
listen 192.168.0.19:443 default_server ssl;
server_name *.mydomain.com;
ssl_certificate
ssl_certificate_key
...
proxy_pass http://upstreams; we pass request to upstream based on some url conditions
}
[/code]
Now if I want to force redirect http to https for only 1 specific domain abc.mydomain.com and leave the rest remains the same, what should I do ?
I tried :
[code]
server {
listen 192.168.0.19:80;
server_name abc.mydomain.com;
return 301 https://$host$request_uri;
}

server {
listen 192.168.0.19:80; # we serve both http and https
listen 192.168.0.19:443 default_server ssl;
server_name *.mydomain.com;
ssl_certificate
ssl_certificate_key
...
proxy_pass http://upstreams; we pass request to upstream based on some url conditions
}
[/code]
But it doesn't work.
Please give me some advice, thank you very much.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>