我试图通过http://localhost:8343/
访问我的服务器,但是它总是显示错误:
400个错误请求 普通HTTP请求已发送到HTTPS端口 nginx/1.14.2
这是我对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*/
有人能帮我弄清楚吗?我被困在这上面好几天了:
发布于 2019-09-12 02:23:22
在你的docker-compose.yaml
->
ports:
- "8180:80"
- "8343:443" <------ Here you bind the host port 8343 to container's port 443
在nginx文件->中
server {
listen 8343 ssl;
listen 443 ssl; <------ you configured that port to listen https traffic
所以你要么去拜访http://localhost:8180要么去访问http://localhost:8180或https://localhost:8343
发布于 2021-02-20 12:23:03
Nginx配置不适合我。我有不安全的注册表配置,由反向代理nginx保护,这增加了TLS加密和基本身份验证。
对我来说,解决方案是在注册表配置/etc/docker/ registry /config.yml的http部分添加“相对人:真”
...
http:
addr: :5000
relativeurls: true
headers:
X-Content-Type-Options: [nosniff]
...
https://stackoverflow.com/questions/57901036
复制相似问题