I recently pass all my site to https here is a sample of cv site conf
server {
listen 80;
server_name cv.host.com;
root /www/cv/app;
index index.html index.htm index.php;
access_log /www/log/cv/nginx-access.log;
error_log /www/log/cv/nginx-error.log;
location /
{
try_files $uri $uri/ =404;
}
location ~ \.php$
{
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/cv.host.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/cv.host.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
if ($scheme != "https") {
return 301 https://$host$request_uri;
} # managed by Certbot
}
But when i try to open http://cv.host.com
my browser got redirected to https://host.com
au lieu de https://cv.host.com
Ngninx seem to cal my default conf which is
server {
listen 80 default_server;
server_name _;
root /www/default/app;
index index.html index.htm index.php;
access_log /www/log/default/nginx-access.log;
error_log /www/log/default/nginx-error.log;
location /
{
try_files $uri $uri/ =404;
}
location ~ \.php$
{
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
listen 443 ssl default_server;
ssl_certificate /etc/letsencrypt/live/host.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/host.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
if ($scheme != "https") {
return 301 https://$host$request_uri;
} # managed by Certbot
}
So when i ask http://cv.host.com i don't get the good site in https... is my config wrong? Any other way to redirect all to https?