-
run certbot
sudo certbot --nginx -d mydomain.com -d mysubdomain.mydomain.com
-
go
/etc/nginx/sites-available/default
-
edit and paste
server { if ($host = mysubdomain.mydomain.com) { return 301 https://$host$request_uri; } # managed by Certbot listen 80; listen [::]:80; server_name mysubdomain.mydomain.com; return 301 https://$host$request_uri; } server { ssl on; ssl_certificate /etc/letsencrypt/live/mysubdomain.mydomain.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/mysubdomain.mydomain.com/privkey.pem; # managed by Certbot listen 443 ssl; listen [::]:443 ssl; server_name mysubdomain.mydomain.com; location / { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_pass http://localhost:3000/; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } }
-
test whether you have typed correctly
sudo nginx -t
-
restart nginx
sudo systemctl reload nginx
Last active
June 12, 2019 14:27
-
-
Save dipsywong98/66559f2a14b59d40a0c423d53a52ef02 to your computer and use it in GitHub Desktop.
Setup new subdomain on NginX with redirected SSL
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment