visiblevc / wordpress-starter

A slightly less shitty wordpress development workflow
688 stars 167 forks source link

Unpredictable Redirects #128

Closed lukasholzer closed 6 years ago

lukasholzer commented 6 years ago

Hey I have the problem, that when I change the port form 8080 to 9000 everything works as fine – till to the moment when I open the browser and want to visit the url: http://localhost:9000 Then I get redirected to http://localhost:8080 and no page is loaded.

But when I visit: http://localhost:9000/wp-admin i can log into wordpress and edit everything… The problem is that the pages could only be visited through the preview url like: http://localhost:9000/?preview_id=7&preview_nonce=bb79fa8833&preview=true

docker-compose.yml

version: '3'

services:

  wordpress:
    image: visiblevc/wordpress:0.17.0-php7.2
    ports:
      - 9000:80
      - 443:443
    restart: always
    networks:
      - frontend
    depends_on:
      - db
    volumes:
      - ./data:/data # If mysql database dump is as .sql file inside
      - ./uploads:/app/wp-content/uploads
      - ./theme:/app/wp-content/themes/sls
      - ./config/tweaks.ini:/usr/local/etc/php/conf.d/tweaks.ini # Optional tweaks to the php.ini config
    environment:
      DB_NAME: u44750db1
      DB_HOST: db
      DB_PASS: root
      DB_PREFIX: ghth_
      SERVER_NAME: localhost
      ADMIN_EMAIL: lukas.holzer@typeflow.cc
      WP_DEBUG: 'true'
      URL_REPLACE: http://www.sls-eventservice.ch,http://localhost:9000
      PLUGINS: >-
        acf-to-rest-api,
        acf-image-crop-add-on,
        wordpress-importer,
        post-types-order,
        taxonomy-terms-order,
        [soil]https://github.com/roots/soil/archive/3.7.1.zip,
        [sls-tiny-mce]https://github.com/lukasholzer/sls-tiny-mce/archive/master.zip,
        [advanced-custom-fields-pro]https://github.com/wp-premium/advanced-custom-fields-pro/archive/5.6.5.zip,

  frontend:
    networks:
      - frontend
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "4400:4400" # HMR Server
    volumes:
      - ./theme:/opt/hmrserver/theme

  db:
    image: mariadb:10
    networks:
      - frontend
    environment:
      MYSQL_ROOT_PASSWORD: root
    volumes:
      - data:/var/lib/mysql

  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    environment:
      MYSQL_ROOT_PASSWORD: root
    ports:
      - 22222:80

volumes:
  data:
  uploads:
    driver: local

networks:
  frontend:

docker-compose up output

...
wordpress_1   | ===============================================================================
wordpress_1   |                        WordPress Configuration Complete!
wordpress_1   | ===============================================================================
wordpress_1   | [Tue Feb 13 09:46:09.885282 2018] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.25 (Debian) PHP/7.2.0 configured -- resuming normal operations
wordpress_1   | [Tue Feb 13 09:46:09.885575 2018] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'

when I open localhost:9000 in the browser it redirects to localhost:8080 and nothing is going to be logged – but when I open localhost:9000/wp-admin I get the following log and everything works:

wordpress_1   | 172.19.0.1 - - [13/Feb/2018:10:01:29 +0000] "GET /wp-admin/ HTTP/1.1" 200 11379 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
wordpress_1   | 172.19.0.1 - - [13/Feb/2018:10:01:29 +0000] "GET /wp-content/plugins/post-types-order/css/cpt.css HTTP/1.1" 200 1089 "http://localhost:9000/wp-admin/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
wordpress_1   | 172.19.0.1 - - [13/Feb/2018:10:01:29 +0000] "GET /wp-includes/js/thickbox/thickbox.css HTTP/1.1" 200 1267 "http://localhost:9000/wp-admin/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
wordpress_1   | 172.19.0.1 - - [13/Feb/2018:10:01:29 +0000] "GET /wp-content/plugins/advanced-custom-fields-pro/assets/css/acf-global.css HTTP/1.1" 200 6335 "http://localhost:9000/wp-admin/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
wordpress_1   | 172.19.0.1 - - [13/Feb/2018:10:01:29 +0000] "GET /wp-content/plugins/taxonomy-terms-order/css/to.css HTTP/1.1" 200 1180 "http://localhost:9000/wp-admin/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
wordpress_1   | 172.19.0.1 - - [13/Feb/2018:10:01:29 +0000] "GET /wp-content/plugins/taxonomy-terms-order/js/to-javascript.js HTTP/1.1" 200 1967 "http://localhost:9000/wp-admin/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
wordpress_1   | 172.19.0.1 - - [13/Feb/2018:10:01:34 +0000] "POST /wp-admin/admin-ajax.php HTTP/1.1" 200 491 "http://localhost:9000/wp-admin/themes.php" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
dsifford commented 6 years ago

Either rebuild from scratch (e.g. docker-compose down -v && docker-compose up -d), or make sure you also go in and change the values of homeurl and siteurl in the options table.

This is by design of WordPress. Not a bug.

lukasholzer commented 6 years ago

@dsifford Thx for your reply but they are changed to localhost:9000 – so when I go to the wordpress admin under general seetings: wp-admin/options-general.php.

The WordPress Address (URL) and the Site Address (URL) are both on http://localhost:9000/

lukasholzer commented 6 years ago

in the sql file they are with port 9000 as well:

database.sql
...
(1, 'siteurl', 'http://localhost:9000', 'yes'),
...
(37, 'home', 'http://localhost:9000', 'yes'),
...
lukasholzer commented 6 years ago

sorry I figured it out – It was a browser caching problem – the redirect was cached -.-

Thx for help!