我想創建一個基於alpine-fpm的包爲this項目但我無法使基於alpine_mysql的映像通過nginx運行,無論多麼困難我試過了。我得到的問題是,mooodle安裝做了一個重定向循環,因此瀏覽器不提供moodle。使用moodle 3.3.2自定義docker映像與fpm:無盡303重定向循環
nginx的配置是this文件,同時我也嘗試沒有成功這個選項(不COMMITED變化尚):
events {
worker_connections 768;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
charset utf-8;
gzip on;
gzip_disable "msie6";
client_max_body_size 10000M;
server {
listen 80 default_server;
server_name _;
root /var/www/html;
index index.php;
location/{
try_files $uri $uri/ =404;
}
location ~ \.php$ {
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 DOCUMENT_ROOT $document_root;
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 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_param PATH_INFO $fastcgi_path_info;
fastcgi_read_timeout 600;
fastcgi_intercept_errors on;
fastcgi_pass moodle_mysql_alpine:9000;
}
}
}
而且我的碼頭工人,組合爲this文件,它可以重點關注這些行:
#Basic alpine fpm image
alpine_fpm_base:
build:
context: .
dockerfile: dockerfiles/fpm_alpine/Dockerfile_base
image: ellakcy/moodle:alpine_fpm_base
moodle_mysql_alpine_db:
image: mysql
environment:
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
MYSQL_ONETIME_PASSWORD: "yes"
MYSQL_DATABASE: "${MOODLE_DB_NAME}"
MYSQL_USER: '${MOODLE_MYSQL_USER}'
MYSQL_PASSWORD: '${MOODLE_MYSQL_PASSWORD}'
# Mysql Enabled image
nginx:
image: nginx:alpine
ports:
- "7070:80"
volumes:
- './conf/nginx/nginx.conf:/etc/nginx/nginx.conf:ro'
links:
- 'moodle_mysql_alpine'
volumes_from:
- 'moodle_mysql_alpine'
moodle_mysql_alpine:
build:
context: .
dockerfile: dockerfiles/fpm_alpine/Dockerfile_mysql
image: ellakcy/moodle:mysql_maria_fpm_alpine
links:
- "moodle_mysql_alpine_db:moodle_db"
- "alpine_fpm_base"
environment:
MOODLE_DB_HOST: "moodle_mysql_alpine_db"
MOODLE_DB_NAME: "${MOODLE_DB_NAME}"
MOODLE_DB_USER: '${MOODLE_MYSQL_USER}'
MOODLE_DB_PASSWORD: "${MOODLE_MYSQL_PASSWORD}"
MOODLE_ADMIN: "${MOODLE_ADMIN}"
MOODLE_ADMIN_PASSWORD: "${MOODLE_ADMIN_PASSWORD}"
MOODLE_URL: "http://0.0.0.0:7070"
我試圖通過docker-compose rm && docker-compose up moodle_mysql_alpine_db moodle_mysql_alpine nginx
命令運行它。另外關於nginx的的日誌的問題作進一步的調查表明,由於某些原因,nginx的拋出303重定向:
172.25.0.1 - - [30/Sep/2017:21:02:57 +0000] "GET/HTTP/1.1" 303 429 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0"
172.25.0.1 - - [30/Sep/2017:21:02:57 +0000] "GET/HTTP/1.1" 303 429 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0"
172.25.0.1 - - [30/Sep/2017:21:02:57 +0000] "GET/HTTP/1.1" 303 429 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0"
172.25.0.1 - - [30/Sep/2017:21:02:57 +0000] "GET/HTTP/1.1" 303 429 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0"
172.25.0.1 - - [30/Sep/2017:21:02:57 +0000] "GET/HTTP/1.1" 303 429 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0"
172.25.0.1 - - [30/Sep/2017:21:02:57 +0000] "GET/HTTP/1.1" 303 429 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0"
172.25.0.1 - - [30/Sep/2017:21:02:57 +0000] "GET/HTTP/1.1" 303 429 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0"
172.25.0.1 - - [30/Sep/2017:21:02:57 +0000] "GET/HTTP/1.1" 303 429 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0"
172.25.0.1 - - [30/Sep/2017:21:02:58 +0000] "GET/HTTP/1.1" 303 429 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0"
172.25.0.1 - - [30/Sep/2017:21:02:58 +0000] "GET/HTTP/1.1" 303 429 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0"
你的同伴有任何想法,爲什麼出現這種情況?
編輯1:
我試圖按照基於https://moopi.uk/mod/page/view.php?id=78造成這種情況的一個nginx的配置:
events {
worker_connections 768;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
charset utf-8;
gzip on;
gzip_disable "msie6";
client_max_body_size 10000M;
server {
listen 80 default_server;
server_name _;
root /var/www/html;
index index.php;
location/{
try_files $uri $uri/ =404;
}
location ~ \.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 DOCUMENT_ROOT $document_root;
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 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_param PATH_INFO $fastcgi_path_info;
fastcgi_read_timeout 600;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_intercept_errors on;
fastcgi_pass moodle_mysql_alpine:9000;
}
}
}
不過我得到重定向循環。
編輯2:
與命令curl -iv http://0.0.0.0:7070
我獲得以下響應要求:
* Rebuilt URL to: http://0.0.0.0:7070/
* Trying 0.0.0.0...
* Connected to 0.0.0.0 (127.0.0.1) port 7070 (#0)
> GET/HTTP/1.1
> Host: 0.0.0.0:7070
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 303 See Other
HTTP/1.1 303 See Other
< Server: nginx/1.13.3
Server: nginx/1.13.3
< Date: Sun, 01 Oct 2017 09:41:21 GMT
Date: Sun, 01 Oct 2017 09:41:21 GMT
< Content-Type: text/html; charset=UTF-8
Content-Type: text/html; charset=UTF-8
< Transfer-Encoding: chunked
Transfer-Encoding: chunked
< Connection: keep-alive
Connection: keep-alive
< X-Powered-By: PHP/7.0.23
X-Powered-By: PHP/7.0.23
< Location: http://0.0.0.0:7070
Location: http://0.0.0.0:7070
< Content-Language: en
Content-Language: en
<
<!DOCTYPE html>
<html lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Redirect</title>
* Connection #0 to host 0.0.0.0 left intact
</head><body><div style="margin-top: 3em; margin-left:auto; margin-right:auto; text-align:center;">This page should automatically redirect. If nothing is happening please use the continue link below.<br /><a href="http://0.0.0.0:7070">Continue</a></div></body></html>
編輯3:
我試圖用基於https://docs.moodle.org/29/en/Nginx配置,並導致該nginx的配置:
events {
worker_connections 768;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
charset utf-8;
gzip on;
gzip_disable "msie6";
client_max_body_size 10000M;
server {
listen 80 default_server;
server_name _;
root /var/www/html;
index index.php;
location/{
try_files $uri $uri/ =404;
}
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass moodle_mysql_alpine:9000;
}
location /dataroot/ {
internal;
alias /var/moodledata; # ensure the path ends with/
}
}
}
但我仍然得到303重定向循環。
做一個'curl -v'並將相同的輸出添加到你的問題中 –