php - Docker nginx & fpm: For some reason when I visit the mapped port it redirects into port 80 -


i making wordpress solution , "dieting" reasons moving alpine-based images therefore try create docker wordpress image based on wordpress:php7.0-fpm-alpine image.

on managed use external configuration (file) , via volume pass nginx.

server {   listen 80;   root /var/www/html;   index index.php;    location / {     try_files $uri $uri/ /index.php;   }    location ~ .php{     try_files $uri =404;     fastcgi_pass wordpress:9000;     fastcgi_index index.php;     include fastcgi_params;     fastcgi_param  gateway_interface  cgi/1.1;     fastcgi_param  server_software    nginx;     fastcgi_param  query_string       $query_string;     fastcgi_param  request_method     $request_method;     fastcgi_param  content_type       $content_type;     fastcgi_param  content_length     $content_length;     fastcgi_param  script_filename    $document_root$fastcgi_script_name;     fastcgi_param  script_name        $fastcgi_script_name;     fastcgi_param  request_uri        $request_uri;     fastcgi_param  document_uri       $document_uri;     fastcgi_param  document_root      $document_root;     fastcgi_param  server_protocol    $server_protocol;     fastcgi_param  remote_addr        $remote_addr;     fastcgi_param  remote_port        $remote_port;     fastcgi_param  server_addr        $server_addr;     fastcgi_param  server_port        $server_port;     fastcgi_param  server_name        $server_name;     fastcgi_intercept_errors  on;   } } 

but when try visit on browser giving http://localhost:8080 (where map port 80 docker-compose.yml):

version: '2' services:   nginx:     image: nginx:alpine     ports:       - "8080:80"     volumes:       - './conf/nginx/:/etc/nginx/conf.d/:ro'     links:       - "wordpress"     volumes_from:       - "wordpress:ro"    wordpress-db:     image: mariadb     environment:       mysql_random_root_password: "yes"       mysql_onetime_password: "yes"       mysql_database: "wordpress"       mysql_user: '${wordpress_mysql_user}'       mysql_password: '${wordpress_mysql_password}'    wordpress:     build:       context: .       dockerfile: dockerfile     image: ellakcy/wordpressswithplugins:alpine     links:       - wordpress-db     environment:         wordpress_db_host: wordpress-db:/var/run/mysqld/mysqld.sock         wordpress_db_user: '${wordpress_mysql_user}'         wordpress_db_password: '${wordpress_mysql_password}'         wordpress_admin_username: '${wordpress_admin_user}'         wordpress_admin_password: '${wordpress_admin_password}'         wordpress_url: '${wordpress_url}' 

but reason seems redirects port 80.

also when run via docker-compose up command following piece of log:

wordpress_1     | 172.23.0.4 -  18/aug/2017:12:36:57 +0000 "get /index.php" 301 nginx_1         | 172.23.0.1 - - [18/aug/2017:12:36:57 +0000] "get / http/1.1" 301 5 "-" "mozilla/5.0 (x11; ubuntu; linux x86_64; rv:55.0) gecko/20100101 firefox/55.0" "-" wordpress_1     | 172.23.0.4 -  18/aug/2017:12:41:22 +0000 "get /index.php" 301 nginx_1         | 172.23.0.1 - - [18/aug/2017:12:41:22 +0000] "get / http/1.1" 301 5 "-" "mozilla/5.0 (x11; ubuntu; linux x86_64; rv:55.0) gecko/20100101 firefox/55.0" "-" 

so guess reason nginx performs 301 redirect port 80. have idea why happens?

edit 1

i tried set 8080 port nginx configuration too:

nginx configuration:

server {   listen 8080;   root /var/www/html;   index index.php;    location / {     try_files $uri $uri/ /index.php;   }    location ~ .php{     try_files $uri =404;     fastcgi_pass wordpress:9000;     fastcgi_index index.php;     include fastcgi_params;     fastcgi_param  gateway_interface  cgi/1.1;     fastcgi_param  server_software    nginx;     fastcgi_param  query_string       $query_string;     fastcgi_param  request_method     $request_method;     fastcgi_param  content_type       $content_type;     fastcgi_param  content_length     $content_length;     fastcgi_param  script_filename    $document_root$fastcgi_script_name;     fastcgi_param  script_name        $fastcgi_script_name;     fastcgi_param  request_uri        $request_uri;     fastcgi_param  document_uri       $document_uri;     fastcgi_param  document_root      $document_root;     fastcgi_param  server_protocol    $server_protocol;     fastcgi_param  remote_addr        $remote_addr;     fastcgi_param  remote_port        $remote_port;     fastcgi_param  server_addr        $server_addr;     fastcgi_param  server_port        $server_port;     fastcgi_param  server_name        $server_name;     fastcgi_intercept_errors  on;   } } 

docker-compose.yml:

version: '2'     services:       nginx:         image: nginx:alpine         ports:           - "8080:8080"         volumes:           - './conf/nginx/:/etc/nginx/conf.d/:ro'         links:           - "wordpress"         volumes_from:           - "wordpress:ro"        wordpress-db:         image: mariadb         environment:           mysql_random_root_password: "yes"           mysql_onetime_password: "yes"           mysql_database: "wordpress"           mysql_user: '${wordpress_mysql_user}'           mysql_password: '${wordpress_mysql_password}'        wordpress:         build:           context: .           dockerfile: dockerfile         image: ellakcy/wordpressswithplugins:alpine         links:           - wordpress-db         environment:             wordpress_db_host: wordpress-db:/var/run/mysqld/mysqld.sock             wordpress_db_user: '${wordpress_mysql_user}'             wordpress_db_password: '${wordpress_mysql_password}'             wordpress_admin_username: '${wordpress_admin_user}'             wordpress_admin_password: '${wordpress_admin_password}'             wordpress_url: '${wordpress_url}' 

i still same behaviour.

edit 2

i tried use following nginx settings (fot nginx container)

server {   listen 8080;   root /var/www/html;   index index.php;    location / {     try_files $uri $uri/ /index.php?q=$uri&$args;   }    location ~ .php {     try_files $uri =404;     fastcgi_pass wordpress:9000;     fastcgi_split_path_info ^(.+\.php)(/.+)$;     fastcgi_index index.php;     include fastcgi_params;     fastcgi_param  gateway_interface  cgi/1.1;     fastcgi_param  server_software    nginx;     fastcgi_param  query_string       $query_string;     fastcgi_param  request_method     $request_method;     fastcgi_param  content_type       $content_type;     fastcgi_param  content_length     $content_length;     fastcgi_param  script_filename    $document_root$fastcgi_script_name;     fastcgi_param  script_name        $fastcgi_script_name;     fastcgi_param  request_uri        $request_uri;     fastcgi_param  document_uri       $document_uri;     fastcgi_param  document_root      $document_root;     fastcgi_param  server_protocol    $server_protocol;     fastcgi_param  remote_addr        $remote_addr;     fastcgi_param  remote_port        $remote_port;     fastcgi_param  server_addr        $server_addr;     fastcgi_param  server_port        $server_port;     fastcgi_param  server_name        $server_name;     fastcgi_intercept_errors  on;   }  } 

and still see no light in path.

edit 4:

furtermore tried put following content script wp_post_entrypoint.sh:

sed -i "define('wp_home', '${wordpress_path}'); define('wp_siteurl','$wordpress_path');" ${wordpress_path}/wp-config.php 

in order redirect correctly wordpress. still no light in path.

edit 5:

i made apache variant , same behavior. wonder if wp-cli somehow messes installation.

furthermore in apache variant when provide container's internal ip site gets served assets broken expected.

edit 6:

i whiped plain 1 without custom wordpress image , worked charm without 301 redirects custom 1 making behaves. plees keep in mind apache 1 based on wordpress:php7.0-apache one:

version: '2' services: #wordpress   wordpress-db:     image: mariadb     volumes:      - './data/wordpress/db:/var/lib/mysql'     environment:       mysql_root_password: '${wordpress_mysql_root_password}'       mysql_database: wordpress       mysql_user: '${wordpress_mysql_user}'       mysql_password: '${wordpress_mysql_password}'    wordpress:     image: wordpress:php7.0-apache     volumes:       - './data/wordpress/www:/var/www/html'     ports:       - '8085:80'     links:       - wordpress-db     environment:       wordpress_db_host: wordpress-db:/var/run/mysqld/mysqld.sock       wordpress_db_user: '${wordpress_mysql_user}'       wordpress_db_password: '${wordpress_mysql_password}' 

please ensure on when perform installation via wp-cli pass site's url without ant http://, " , '. ensure please run:

wordpress_url=$(php -r "echo preg_replace('#^http?://|\"|\'#', '', rtrim('${wordpress_url}','/'));") 

before performing: wp-cli core install or in case wp ^params^ core install


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -