Before you start
- Your domain’s A record points at this server. Check with
dig +short postqueen.example.com. - Ports 80 and 443 are open. Port 80 is needed to prove you own the domain.
- PostQueen is already running. Confirm with
curl -I http://localhost:4007on the server.
About the port. Under Docker Compose, the normal install,
she is published on the host as 4007, which is the number used throughout this page. Inside
the container she listens on 5000. If you installed her with
Docker on its own she is on
localhost:5000 instead, so change the
proxy_pass lines below accordingly.How to add Nginx as a reverse proxy
The following commands are tailored for Ubuntu/Debian systems. If you are using a different Linux distribution, you may need to adjust package management commands accordingly (e.g.,
yum for CentOS, brew for macOS).1
Install Nginx
2
Install Certbot for SSL
3
Create the Webroot Directory
4
Create a temporary Nginx config for creating SSL certificates
Make sure to change subdomain.domain.tld to your actual subdomain and ensure that it is pointed to your server’s IP address.
/etc/nginx/sites-available/subdomain.domain.tld:5
Obtain SSL Certificates Using Webroot method
6
Edit the Nginx config
Edit the file
/etc/nginx/sites-available/subdomain.domain.tld.- Secure Config (Recommended)
- Simple Config
7
Generate DH Parameters
(Needed if you are using the “robust” nginx config option)
8
Test your Nginx configuration
9
Automatic reload Nginx when SSL Certificates are renewed
10
Reload Nginx
11
Tell PostQueen her address
The proxy works now, but she still believes she lives on Keep the
localhost, and she builds
sign-in origins and every social network’s return address from these values. In your
docker-compose.yaml:/api suffix on the last one, and leave no trailing slashes on any of them. Then
apply the change:12
Check it
From your own machine, not the server:
HTTP/2 200 means the certificate, Nginx and PostQueen are all doing their jobs. Open the
address in a browser and sign in. 🎉If it does not work
502 Bad Gateway
502 Bad Gateway
Nginx is running and PostQueen is not answering on the port it was told to use. Check her
directly on the server with
curl -I http://localhost:4007. If that also fails,
docker compose logs postqueen has the reason. If it succeeds, the proxy_pass line has
the wrong port.413 Request Entity Too Large when uploading
413 Request Entity Too Large when uploading
Nginx caps request bodies at 1 MB by default. The secure config above sets
client_max_body_size 100M; for exactly this reason. If you used the simple config, add
that line inside the server block and reload.The page loads but sign-in does not stick
The page loads but sign-in does not stick
FRONTEND_URL does not match the address in the browser bar, character for character. See
the step above.certbot cannot validate the domain
certbot cannot validate the domain
The temporary HTTP config has to be live and reachable on port 80, and
dig +short postqueen.example.com has to return this server’s IP. Both have to be true at
the moment certbot runs.