Ecommerce Shopify WordPress Discussion

HTTPS not working on WordPress with NGINX and PHP on Ubuntu server

I'm trying to configure a WordPress site with SSL configured. I installed NGINX, PHP (7.4) and MySQL. So when I access the public IP of the server it loads the site successfully. We have set the DNS A record as well. Assume the URL is example.com and when I access example.com it loads the site successfully but not HTTPS secured. I created a new config file in sites-available and sites-enabled and added below content. I removed the config file in /etc/nginx.conf.d/ Content server { listen 80; listen [::]:80; listen 443 ssl default_server; listen [::]:443 ssl default_server; ssl on; root /var/www/html/example.com; index index.php index.html index.htm; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot server_name example.com <ip-of-the-vm>; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.4-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } } I installed certbot and created the certs using: sudo certbot --nginx -d example.com -d www.example.com When I access example.com in the browser it loads the site but not secured. And also I see it redirects (It shows the public IP of the server in the URL/search bar in the browser. It is redirecting?) Modified NGINX config file. server { listen 80; server_name www.example.com example.com; return 301 https://$host$request_uri; } server { listen 443 ssl http2; server_name example.com; root /var/www/html/example.com; index index.php; # SSL parameters ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem; # log files access_log /var/log/nginx/example.com.access.log; error_log /var/log/nginx/example.com.error.log; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.4-fpm.sock; } }
define('WP_SITEURL', 'http://example.com'); define('WP_HOME', 'http://example.com'); Added the above wp-config.php and started to work

January 7, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.