After installing let’s encrypt via certbot my wordpress website has stopped loading css/js properly. It always returns Blocked loading mixed active content
. If I change http://example.com
to https://example.com
in WP admin panel website server returns too many redirections
error.
Here are some details.
My Nginx Config
server {
server_name example.com www.example.com
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8000;
include /etc/nginx/mime.types;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/vergisistemi.az/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/vergisistemi.az/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name example.com www.example.com;
return 301 https://$host$request_uri;
# return 404; # managed by Certbot
}
Here is what docker ps
returns:
CONTAINER ID IMAGE PORTS NAMES
571d2d2c7e12 wordpress:latest 0.0.0.0:8000->80/tcp, :::8000->80/tcp wordpress
265b6e159bc2 mysql:5.7 3306/tcp, 33060/tcp mysql
2
Answers
After a half day in a searching for solution I figured out that some minor changes need to be made:
1st - adding
define('FORCE_SSL_ADMIN', true);
towp-config.php
file;2nd - adding
proxy_set_header X-Forwarded-Proto $scheme;
tolocation
in nginx config file:And voilĂ ! Everything works smoothly!
Adding this code to the top of wp-config.php did the trick for me: