• I have a site I’ve been running for ages in a VM on various providers. I decided to move it to using Containers. To first make sure things were going to work, I set it up with port 80 exposed. Everything worked great.

    Then I changed it to a different port. (I’ve tried 8008, 8081, etc)

    I know it’s not a firewall issue because on the VM I’m running the container on, there is no firewall.

    When I do a curl, I get a redirect:

    curl -v localhost:8008
    *   Trying ::1:8008...
    * connect to ::1 port 8008 failed: Connection refused
    *   Trying 127.0.0.1:8008...
    * Connected to localhost (127.0.0.1) port 8008 (#0)
    > GET / HTTP/1.1
    > Host: localhost:8008
    > User-Agent: curl/7.69.1
    > Accept: */*
    > 
    * Mark bundle as not supporting multiuse
    < HTTP/1.1 301 Moved Permanently
    < Date: Sat, 17 Oct 2020 18:51:57 GMT
    < Server: Apache/2.4.38 (Debian)
    < X-Powered-By: PHP/7.4.11
    < X-Redirect-By: WordPress
    < Location: https://localhost/
    < Content-Length: 0
    < Content-Type: text/html; charset=UTF-8
    < 
    * Connection #0 to host localhost left intact

    I find this odd because the container should be seeing the request as coming from 80, should it not?

    CONTAINER ID  IMAGE                               COMMAND               CREATED         STATUS             PORTS                                                                NAMES
    64ad07efd4da  docker.io/library/mariadb:10.5      mysqld                22 minutes ago  Up 22 minutes ago  0.0.0.0:8008->80/tcp, 0.0.0.0:8443->443/tcp, 0.0.0.0:8082->8080/tcp  wordpress_db
    b71a5cf0c0dc  k8s.gcr.io/pause:3.2                                      22 minutes ago  Up 22 minutes ago  0.0.0.0:8008->80/tcp, 0.0.0.0:8443->443/tcp, 0.0.0.0:8082->8080/tcp  979ae13e34da-infra
    e52178bc560e  docker.io/library/wordpress:latest  apache2-foregroun...  22 minutes ago  Up 22 minutes ago  0.0.0.0:8008->80/tcp, 0.0.0.0:8443->443/tcp, 0.0.0.0:8082->8080/tcp  wordpress
    

    I looked at a few different Docker posts here, but none seemed to match this. Maybe people did the initial set up their WordPress blogs on that other port? I know when I ran this on a computer in my homelab, I can run a fresh WP install on another port in a Docker container and it works just fine.

    Eventually the goal is to have nginx in front of all of this and parceling off port 80 requests to different containers based on the domain name coming in. So I would need WordPress to be OK with being on another port so that I can pass it on.

    Thanks!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • I looked at a few different Docker posts here, but none seemed to match this.

    There may not be many WordPress support volunteers here who are deep into Docker containers to help you out.

    And for the record, what you’re calling “WordPress official docker container” is actually a 3rd-party product built and distributed by Docker, not WordPress, as stated in this Docker documentation page. WordPress has never released any docker container.

    If you don’t get the help you seek here, I’ll advise you use the support channels recommended by Docker: see “Where to go for help” on this page: https://hub.docker.com/_/wordpress/

    Good luck!

    Thread Starter ericmesa

    (@ericmesa)

    Ok, let’s pretend I’m not using docker.

    If I wanted to convert a WordPress install that’s been runnign on port 80 to run on port 8008 and have nginx answer at 80 and pass it on to WordPress. What would I change with my already functioning (not brand new) WP install?

    If I wanted to convert a WordPress install that’s been runnign on port 80 to run on port 8008

    The full WordPress site address is saved in the database. For port 80, the port number is left out because it’s the default, so, in your case, you only have https://localhost/.

    If you switch your webserver to run on 8008, the port number must now be included in the addressing scheme, so your new address becomes https://localhost:8008.

    Meanshile your WordPress database still has https://localhost/ — and you need to change this in your database to have WordPress run on the new port.

    I have no idea how this translates to a docker environment behind an Nginx proxy.

    Good luck!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WordPress official docker container image causing redirects when not on port 80’ is closed to new replies.