Category: Troubleshooting

  • Setting up a Reverse Proxy for WordPress in Docker

    I had a WordPress site running inside a single Docker container on an Ubuntu server hosted on Oracle Cloud. This container included both the WordPress application and the Apache web server. The container’s port 80 was mapped to the host’s port 8080, allowing access to the site via http://207.211.xxx.xxx:8080. I owned the domain leeveschou.com and wanted to serve the WordPress site securely over HTTPS using this domain.

    Purpose

    The goal was to configure a reverse proxy setup so that requests to https://leeveschou.com would be securely routed to the WordPress site running inside the Docker container. I preferred to use Apache, which was running inside the Docker container alongside WordPress. The aim was to:

    • Serve the WordPress site on the standard HTTPS port (443) under my domain
    • Use SSL certificates I already had
    • Avoid exposing the non-standard port 8080 to users
    • Ensure smooth, secure access to the WordPress site

    Issues Encountered

    Redirects to Port 8080

    After setting up SSL, accessing https://leeveschou.com resulted in a redirect to https://leeveschou.com:8080/, which was inaccessible externally.

    Cause:

    WordPress’s Site Address (URL) and WordPress Address (URL) were still set to http://207.211.xxx.xxx:8080, causing WordPress to redirect to that port.

    Sequence Diagram of Incorrect Setup

    sequenceDiagram
        participant Client as Browser (leeveschou.com)
        participant DNS as DNS Server
        participant Host as Ubuntu Server (207.211.xxx.xxx)
        participant Docker as Docker Container (Apache + WordPress)
    
        Client->>DNS: Resolve leeveschou.com
        DNS-->>Client: Return 207.211.xxx.xxx
    
        Client->>Host: HTTPS request to 207.211.xxx.xxx:443 (Host port 443)
        Host->>Docker: Forward request to container port 443
        Docker->>Client: Respond with 301 Redirect to https://leeveschou.com:8080/
    
        Client->>Host: HTTPS request to 207.211.xxx.xxx:8080 (Host port 8080)
        Note right of Client: Port 8080 not open or no SSL
        Host-->>Client: Connection refused or timeout
    

    Solution:

    • Updated both URLs in the WordPress admin dashboard to https://leeveschou.com
    • Alternatively, updated the URLs directly in the SQLite database used by WordPress
    • Ensured Apache inside the container had no redirect rules forcing port 8080
    • Restarted Apache and cleared browser cache

    Sequence Diagram without Redirect

    sequenceDiagram
        participant Client as Browser (leeveschou.com)
        participant DNS as DNS Server
        participant Host as Ubuntu Server (207.211.xxx.xxx)
        participant Docker as Docker Container (Apache + WordPress)
    
        Client->>DNS: Resolve leeveschou.com
        DNS-->>Client: Return 207.211.xxx.xxx
    
        Client->>Host: HTTPS request to 207.211.xxx.xxx:443 (Host port 443)
        Host->>Docker: Forward request to container port 443
        Docker->>Docker: Apache serves WordPress content
        Docker-->>Client: Respond with 200 OK and HTML content