I just had to deal with the same troubles perhaps.
My main goal was to use one physical server for several websites. Each website would have wordpress hosted by it's own nginx server, living inside it's own Ubuntu container.
To keep those all silo'd, I wanted them all behind an Nginx reverse proxy, which also lives on a separate container.
The usual LEMP installations were easy enough on the Ubuntu containers, although I found that the current LXC ubuntu image includes Apache2 .. sudo apt remove apache2 was the fix for that one.
To enable HTTPS, the Certbot installation only needs to be done on your reverse proxy, which will then provide certificates valid for all of your domains.
There were 2 special steps to facilitate the Nginx reverse proxy:
1 - On your 'reverse proxy' container, headers like the following need to be included in your server {} block in each of your /etc/nginx/sites-enabled/yourDetailedSites files: (I've left the # comments on the individual fields that I'm not sure are required or not)
#######################################################################
server {
server_name your.example.domain;
location / {
# proxy_pass_header Authorization;
proxy_pass http://xx.xx.xx.xx:80;
# 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;
proxy_set_header X-Forwarded-Proto https;
}
listen 443 ssl; # managed by Certbot
... there will be more in here after the Certbot installation ...
}
server {
if ($host = your.example.domain) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name your.example.domain;
listen 80;
return 404; # managed by Certbot
}
#######################################################################
2 - Within your individual containers acting as each of the proxy_pass recipients, once wordpress is installed, you need to edit your wp-config.php file to include the following code. This needs to be customized for your.domain.name vs 'www.mydomain.com' and you'll need to add this just below the 'salts' area, but before the php really gets going.
////////////////////////////////////////////////////////////////
define('.COOKIE_DOMAIN.', 'my.example.org');
define('.SITECOOKIEPATH.', '.');
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$list = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
$_SERVER['REMOTE_ADDR'] = $list[0];
}
define( 'WP_HOME', 'https://my.example.org' );
define( 'WP_SITEURL', 'https://my.example.org' );
$_SERVER['HTTP_HOST'] = 'my.example.org';
$_SERVER['REMOTE_ADDR'] = 'https://my.example.org';
$_SERVER[ 'SERVER_ADDR' ] = 'my.example.org';
if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
$_SERVER['HTTPS']='on';
////////////////////////////////////////////////////////////////
Once I did the above, I was able to use the '5 minute sign-in' and edit my wordpress sites.