Migrate existing worpress sites behind a reverse proxy (lxd)

Viewed 22

I want to put a proxy container with Nginx to handle traffic to my other containers with WordPress sites.

I am currently using the following setup:

Internet <--> webservices.lxd (added port 80 && 443 to the container) <--> example.com (apache2)

The new setup should look like this:

Internet <--> proxy.lxd (added port 80 && 443 to the container)(nginx) <--> webservices.lxd <--> example.com (apache2)

So in short: I would like to put a reverse proxy container handling all the traffic between lxd containers.

Here is the Nginx reverse proxy config file:

server {

    server_name example.com;

location / {
                include /etc/nginx/proxy_params;
                proxy_pass http://webservices.lxd;
        }

        real_ip_header proxy_protocol;
        set_real_ip_from 127.0.0.1;


listen [::]:443 ssl proxy_protocol; # managed by Certbot
listen 443 ssl proxy_protocol; # managed by Certbot
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
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
if ($host = example.com) {
    return 301 https://$host$request_uri;
} # managed by Certbot


    listen 80 proxy_protocol;
    listen [::]:80 proxy_protocol;

    server_name example.com;
return 404; # managed by Certbot

}

Here is the apache2 site config from within the (current with no proxy) web services container:

root@webservices:/etc/apache2/sites-available# cat example.com.at-le-ssl.conf 
   <IfModule mod_ssl.c>
   <VirtualHost *:443>
     DocumentRoot "/var/www/example.com/htdocs"
     ServerName example.com
     UseCanonicalName On
# Security Section
     Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains"
# Security Section Ende
 
 <Directory "/var/www/example.com/htdocs/">
     Options MultiViews FollowSymlinks
     AllowOverride All
     Order allow,deny
     Allow from all
</Directory>

TransferLog /var/log/apache2/example.com_access.log
ErrorLog /var/log/apache2/example.com_error.log


Include /etc/letsencrypt/options-ssl-apache.conf
ServerAlias www.example.com
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>
</IfModule>
<IfModule mod_ssl.c>
<VirtualHost *:80>
ServerName example.com
ServerAlias *example.com

<Location "/">
        Redirect permanent "https://%{HTTP_HOST}%{REQUEST_URI}"
</Location>


</VirtualHost>
</IfModule>

My questions are:

A. What do I need to change to run the new proxy setup?

B. Do I need to change something else (WordPress wp-config.php or else)?

C. Besides: the database server is also running within the web service container. Should I also make a new container for the databases?

Here are the two tutorials I already tried but did not work for my "migration" case: https://www.linode.com/docs/guides/how-to-set-up-multiple-wordpress-sites-with-lxd-containers/

https://www.linode.com/docs/guides/beginners-guide-to-lxd-reverse-proxy/

0 Answers
Related