I'm trying to access my server thru http://localhost:8343/
but it always displays the error:
400 Bad Request
The plain HTTP request was sent to HTTPS port
nginx/1.14.2
Here is my configuration for docker-compose.yml .
/*other configurations*/
services:
pages:
build:
context: .
dockerfile: ./pages/Dockerfile
container_name: proj_idcf_pages_1
ports:
- "8180:80"
- "8343:443"
environment:
- TZ=Asia/Tokyo
- LA_PROJECT_DIR=laravel
depends_on:
- php7
volumes:
- ../service/pages/:/var/www/
- ./ssl_key/:/etc/nginx/ssl_key
networks:
- proj_default
/*other configurations*/
pages/Dockerfile
FROM centos:centos7
FROM nginx:1.14.2
COPY pages/default.conf /etc/nginx/conf.d/default.conf
RUN sed -i -e "s/access_log .*;$/access_log \/dev\/stdout;/g" /etc/nginx/nginx.conf
RUN sed -i -e "s/error_log .*;$/error_log \/dev\/stderr debug;/g" /etc/nginx/nginx.conf
CMD ["nginx", "-g", "daemon off;"]
pages/default.conf
server {
listen 80;
rewrite ^(.*)$ http://localhost:8343$1 permanent;
}
server {
listen 8343 ssl;
listen 443 ssl;
index index.php;
server_name localhost:8180;
error_log /dev/stderr debug;
access_log /dev/stdout;
root /var/www/laravel/public;
ssl_certificate /etc/nginx/ssl_key/localhost.pem;
ssl_certificate_key /etc/nginx/ssl_key/localhost.key;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php7:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
add_header my_string 'start';
add_header $request_filename $request_filename;
add_header my_document_root $document_root;
add_header fastcgi_script_name $fastcgi_script_name;
add_header my_fastcgi_path_info $fastcgi_path_info;
add_header my_string_2 ‘end’;
}
/*other settings*/
can someone help me figure this out? I'm stuck on this for days now :(
In your docker-compose.yaml
->
ports:
- "8180:80"
- "8343:443" <------ Here you bind the host port 8343 to container's port 443
and in the nginx conf file ->
server {
listen 8343 ssl;
listen 443 ssl; <------ you configured that port to listen https traffic
So you have either to visit http://localhost:8180 or https://localhost:8343
Nginx configuration did not work for me. I had unsecure registry configuration, protected by reverse proxy nginx, which added TLS encryption and basic authentication.
For me solution was to add "relativeurls: true" to http part of registry configuration /etc/docker/registry/config.yml
...
http:
addr: :5000
relativeurls: true
headers:
X-Content-Type-Options: [nosniff]
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.