Joplin + Nginx Reverse Proxy On Custom Port Not Working

Operating system

Linux

Joplin version

3.4.10

Sync target

Joplin Server

What issue do you have?

I've set up my own Joplin server with docker compose, using Nginx as the reverse proxy. This server is only intended to be accessed within my private network, but I still want to use HTTPS.

I can get everything set up with Nginx listening on the default port for HTTPS (443). However, when I try to use a custom port (port "12345" for example), I get the "Invalid origin: http://server_ip_address" error.

How can I get this working properly?

Note: If I remove the port number from APP_BASE_URL, when I visit the server on my browser, the request hangs for a while, then I get redirected to the login page (without the port number), then the request hangs a bit longer, until finally the browser says the server took too long to respond.

.env

APP_BASE_URL=https://192.168.1.REDACTED:12345
APP_PORT=22300
DB_CLIENT=pg
POSTGRES_PASSWORD=REDACTED
POSTGRES_DATABASE=REDACTED
POSTGRES_USER=REDACTED
POSTGRES_PORT=5432

TRANSCRIBE_ENABLED=false

docker-compose.yml

services:
    db:
        image: postgres:16
        volumes:
            - /REDACTED:/var/lib/postgresql/data
        expose:
            - "5432"
        restart: unless-stopped
        environment:
            - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
            - POSTGRES_USER=${POSTGRES_USER}
            - POSTGRES_DB=${POSTGRES_DATABASE}
    joplin_server:
        image: joplin/server:latest
        depends_on:
            - db
        expose:
            - "22300"
        restart: unless-stopped
        environment:
            - APP_PORT=${APP_PORT}
            - APP_BASE_URL=${APP_BASE_URL}
            - DB_CLIENT=${DB_CLIENT}
            - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
            - POSTGRES_DATABASE=${POSTGRES_DATABASE}
            - POSTGRES_USER=${POSTGRES_USER}
            - POSTGRES_PORT=${POSTGRES_PORT}
            - POSTGRES_HOST=db
            - TRANSCRIBE_ENABLED=${TRANSCRIBE_ENABLED}
    nginx:
        image: nginx:latest
        ports:
            - "12345:12345"
        restart: unless-stopped
        volumes:
            - /REDACTED:/etc/nginx/conf.d/:ro
            - /REDACTED:/etc/nginx/certs:ro
        depends_on:
            - joplin_server

nginx.config

server {
    listen 12345 ssl http2;
    server_name 192.168.1.REDACTED;

    ssl_certificate /etc/nginx/certs/fullchain.pem;
    ssl_certificate_key /etc/nginx/certs/cert-key.pem;

    location / {
        proxy_pass http://joplin_server:22300;
        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-Proto $scheme;
		proxy_set_header X-Forwarded-Host $host;
    }
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.