Skip to main content
Nginx puts PostQueen on your domain with HTTPS. It takes more configuration than Caddy and handles certificates through a separate tool, so it is the right choice mainly when you already run Nginx for other things. If you are not sure what a reverse proxy is or why she needs one, Domain and HTTPS explains it first.

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:4007 on 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.
Edit the file /etc/nginx/sites-available/subdomain.domain.tld:
Then create the symlink:
5

Obtain SSL Certificates Using Webroot method

6

Edit the Nginx config

Edit the file /etc/nginx/sites-available/subdomain.domain.tld.
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 localhost, and she builds sign-in origins and every social network’s return address from these values. In your docker-compose.yaml:
Keep the /api suffix on the last one, and leave no trailing slashes on any of them. Then apply the change:
Skipping this step is the most common way to end up with a working padlock and a site you cannot sign in to. The certificate is not the problem in that case, these three values are.
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

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.
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.
FRONTEND_URL does not match the address in the browser bar, character for character. See the step above.
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.