首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >普通HTTP请求被发送到HTTPS端口错误Docker nginx

普通HTTP请求被发送到HTTPS端口错误Docker nginx
EN

Stack Overflow用户
提问于 2019-09-11 22:41:09
回答 2查看 5K关注 0票数 3

我试图通过http://localhost:8343/访问我的服务器,但是它总是显示错误:

400个错误请求 普通HTTP请求已发送到HTTPS端口 nginx/1.14.2

这是我对docker-compose.yml.的配置

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
/*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

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
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

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
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*/

有人能帮我弄清楚吗?我被困在这上面好几天了:

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-09-12 02:23:22

在你的docker-compose.yaml ->

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
ports:
   - "8180:80"  
   - "8343:443" <------ Here you bind the host port 8343 to container's port 443

在nginx文件->中

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
server {
    listen 8343 ssl;
    listen 443 ssl; <------ you configured that port to listen https traffic

所以你要么去拜访http://localhost:8180要么去访问http://localhost:8180https://localhost:8343

票数 4
EN

Stack Overflow用户

发布于 2021-02-20 12:23:03

Nginx配置不适合我。我有不安全的注册表配置,由反向代理nginx保护,这增加了TLS加密和基本身份验证。

对我来说,解决方案是在注册表配置/etc/docker/ registry /config.yml的http部分添加“相对人:真”

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
...
http:
  addr: :5000
  relativeurls: true
  headers:
    X-Content-Type-Options: [nosniff]
...
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57901036

复制
相关文章
Nginx代理HTTPS到Docker指定端口
假设我在服务器上的 Docker 运行了一个应用,在 Docker 启动的时候,我指定他监听了 localhost 的 9000 端口,定向到 Docker 的 9002 的应用上。
凝神长老
2020/04/17
1.8K0
详解https请求Nginx转发tomcat变成http问题
简单架构为nginx做负载均衡,后端用tomcat做容器。浏览器和 Nginx 之间走的 HTTPS 通讯,而 Nginx 到 Tomcat 通过 proxy_pass 走的是普通 HTTP 连接。
IT大咖说
2021/02/24
4.6K0
详解https请求Nginx转发tomcat变成http问题
python部署-nginx部署带docker的https请求
首先例如使用https://www.Se7eN_HOU.com进行首页访问,首先会先进入到主服务器里面,经过主服务器的Nginx Web服务器,进行web服务。这时主服务器的nginx就会监听80端口,收到这个请求
Se7eN_HOU
2020/04/24
1.2K0
Nginx配置SSL实现https请求并重定向http请求的实现
因为我的网站是部署在腾讯云上的,腾讯云同时也提供了免费的SSL证书(有效期1年)。
Bug生活2048
2018/08/31
3.9K0
Nginx配置SSL实现https请求并重定向http请求的实现
docker registry push错误“server gave HTTP response to HTTPS client”
上传报错 Docker execution failed   Command line [docker push xxx.xxx.xxx.xxx:5000/xxx:0.0.1-SNAPSHOT] returned:   Get https://xxx.xxx.xxx.xxx:5000/v1/_ping: http: server gave HTTP response to HTTPS client
似水的流年
2019/12/07
2.4K0
Nginx的默认端口是_https默认端口
我们首先用whereis nginx.conf来看一下哪些目录里面有nginx.conf文件,我们看到了一共有6个目录,这里是应该分别到这六个文件里面去看一下,但是由于我们提前找过了,是/etc/nginx这个目录,所以我们就直接到该目录下面,即采用cd来切换目录,下图已经把这个文件标出来了。
全栈程序员站长
2022/10/05
2.3K0
Nginx的默认端口是_https默认端口
nginx 全站 http 跳转 https
lukachen
2023/10/22
2820
nginx转发http请求
大家好,又见面了,我是你们的朋友全栈君。 原路径: http://source.server.com/callback/test/test?username=xx 转发到:http://10.1.9
全栈程序员站长
2022/11/02
9210
nginx转发https到http
微信小程序和公众号,要求外链的页面或API必须使用https。https意味着需要证书,在测试阶段,很不方便,因此部署的测试站点都是http。于是尝试在现有的https站点中,用nginx转发请求到只有http的测试站点。
全栈程序员站长
2022/11/02
2.1K0
Nginx请求转发&端口转发
nginx反向代理 官网介绍:https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/
mingjie
2022/05/12
4K0
Docker容器https请求报错
某一天,我在使用 docker 的时候遇到个奇怪的问题,在容器里面发起 https 请求报了个错。 经过测试发现在容器里面发起的所有 https 请求都报错,即使是 curl 发起 https 请求也报错。 而 http 请求却能正常发起请求。
epoos
2023/08/24
1.3K0
Docker容器https请求报错
Https网站中请求Http内容
今天遇到个问题:```Mixed Content: The page at ‘https://*****’ was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint ‘http://*****’. This request has been blocked; the content must be served over HTTPS```
DannyHoo
2020/06/15
23.2K0
设置HTTP请求自动跳转HTTPS
server { listen 80; server_name localhost ; location / { index index.html index.htm; } } server { listen 443 ssl; server_name localhost; root html; index index.html index.htm; ssl_certificate cert/domain name.pem; #将domain name.pem替换成您证书的文件名。 ssl_certificate_key cert/domain name.key; #将domain name.key替换成您证书的密钥文件名。 ssl_session_timeout 5m;
1900
2022/12/03
2.6K0
编译nginx支持https+http2+nginx-http-concat模块
现在很多网站要求https访问,既能提高安全性,也避免运营商劫持。又必须给nginx加上这些功能。
保持热爱奔赴山海
2019/09/18
6900
nginx实现http自动跳转https
在使用 Nginx 作为 Web 服务器时,您可以通过配置实现 HTTP 自动跳转 HTTPS。这可以确保用户始终使用 HTTPS 访问您的网站,从而提高网站的安全性。
堕落飞鸟
2023/03/30
6.5K0
nginx从http跳转到https
项目前期使用http,后期为了安全方面的考虑,启用了https。 项目架构:前端使用nginx作为多个tomcat实例的反向代理和负载均衡。 实际上只需要在nginx上启用https即可,使客户端与nginx之后使用https方式通信,而nginx与tomcat之间依然以http方式通信。
编程随笔
2019/09/11
13.8K0
Nginx配置Https并进行Http强制跳转Https
首先我们先了解为什么要做https? https现在是一个趋势这样在别人去访问的时候是会显示一个安全的连接,可以去看看各大网站等… 先获取证书 这里就不介绍了 获取的地方有很多 可以进行正规渠道的购买或者使用openssl工具进行获取
互联网-小阿宇
2022/11/21
1.8K0
Nginx配置Https并进行Http强制跳转Https
Nginx实现http和https复用1个端口的2种解决方式
http是明文传输,数据在传输时没有加密,存在被读取和修改数据的风险,http传输敏感信息如密码等不够安全。
六月河
2023/06/26
10.2K0
Nginx实现http和https复用1个端口的2种解决方式
点击加载更多

相似问题

普通HTTP请求被发送到HTTPS端口(NGINX)

30

Nginx http到http重定向400普通HTTP请求被发送到HTTPS端口

17

处理nginx 400“简单的HTTP请求被发送到HTTPS端口”错误

101

aws >>上的nginx码头集装箱普通HTTP请求被发送到HTTPS端口

11

Chilkat HTTPS将普通HTTP请求发送到HTTPS端口

147
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文