Set up HTTPS using Let's Encrypt and NGINX

Published: 01 October 2020
on channel: DevbaseMedia
8,363
174

We will finally set up HTTPS access on our Wordpress Docker instance running on Google Cloud Platform. Although this shows setup for Wordpress, this will work for anything running via an NGINX reverse proxy. As usual, everything demonstrated in this video is free; in this case the SSL/TLS certs are provided by LetsEncrypt.

Previous videos:
Registering a domain with Google Domains:    • How to transfer domains from GoDaddy ...  
Creating a Wordpress instance on GCP:    • Run Wordpress for Free Forever with G...  
How to Point your Domain at a Google Cloud Instance:    • How to Point your Domain at a Google ...  
Point an NGINX Reverse Proxy to Wordpress Running on Docker:    • Point an NGINX Reverse Proxy to Wordp...  



Commands to set up certbot:
sudo apt install software-properties-common && sudo apt update
sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt install -y python-certbot-nginx
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
sudo service nginx restart



Code snippet for wp_config.php:
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
$_SERVER['HTTPS']='on';

if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}

Code snippet for nginx configuration:
server {
root /var/www/html;
listen 80;
listen [::]:80;
server_name yourdomain.com www.yourdomain.com;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto $scheme;
}
}


GitHub repo: https://github.com/chrisbmatthews/wor...

Google Cloud Platform: https://cloud.google.com


Watch video Set up HTTPS using Let's Encrypt and NGINX online without registration, duration hours minute second in high quality. This video was added by user DevbaseMedia 01 October 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 8,363 once and liked it 174 people.