UPDATE: I solved the problem with the mixed content with a plugin The main problem now is that when I go to the admin login page I get redirected to the login page inside <> instead my domain
I have a Rails application on Amazon Elastic Beanstalk, behind an Amazon Elastic Load Balancer. On the same servers as the Rails application I have a nginx server with reverse proxy to a Wordpress blog on a different server. (So it can be accessed as example.com/blog)
Our domain is on GoDaddy, there I have a forwarding rule, from example.com to https://www.example.com. The domain itself is forwarded to the CNAME of the ELB
On the Load Balancer there is a listener for port 443 and it's forwarded to port 80
Inside the server I have a rule that is forcing a redirection from http to https
When I used a single server without the Load Balancer the reverse proxy worked flawlessly, but since I started using it, the blog's assets are not loaded properly and I get the mixed content error.
nginx config that works without the elb:
server {
listen 80;
server_name <<rails-app-domain>>;
if ($time_iso8601 ~ "^(d{4})-(d{2})-(d{2})T(d{2})") {
set $year $1;
set $month $2;
set $day $3;
set $hour $4;
}
access_log /var/log/nginx/access.log main;
access_log /var/log/nginx/healthd/application.log.$year-$month-$day-$hour healthd;
location /health_check {
access_log off;
return 200;
}
location / {
if ($http_x_forwarded_proto != 'https') {
return 301 https://$server_name$request_uri;
}
proxy_pass http://my_app;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ^~ /blog {
proxy_pass http://<<wordpress-server-ip>>/blog;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect http://<<wordpress-server-ip>>/ https://$host/;
proxy_cookie_domain <<wordpress-server-ip>> $host;
}
location /assets {
alias /var/app/current/public/assets;
gzip_static on;
gzip on;
expires max;
add_header Cache-Control public;
}
location /public {
alias /var/app/current/public;
gzip_static on;
gzip on;
expires max;
add_header Cache-Control public;
}
location /cable {
proxy_pass http://my_app;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
wordpress wp-config.php:
define('WP_SITEURL', 'https://<<rails-app-domain>>/blog');
define('WP_HOME', 'https://<<rails-app-domain>>/blog');
define('FORCE_SSL_ADMIN', true);
What I tried:
- Setting a sub filter for http -> https rewrite rule for all the locations inside /blog
- A redirect rule for all the locations inside /blog from http to https
Adding a listener for port 443 in nginx and redirecting port 443 of the load balancer to port 443 of the server (instead of 80 like before)
Removing the domain forwarding on GoDaddy