Nginx重定向https-> http(反向代理)->端口(docker容器) [英] Nginx redirect https->http(reverse proxy)->port(docker container)

查看:105
本文介绍了Nginx重定向https-> http(反向代理)->端口(docker容器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文

简单设置

  • 将8090作为网站(节点,快速)公开的docker容器
  • 暴露80的nginx conf并将其映射到localhost 8090

问题

我没有支付SSL证书,我希望尝试访问https的最终用户重定向到http.

I don't have paid SSL certificate, I want end users that try to reach https to be redirected to http.

我尝试了重定向,重写,并在下面进行了简单的侦听..没有成功.浏览器将返回"ERR_SSL_PROTOCOL_ERROR".

I have tried redirects, rewrite, and here below a simple listen.. without success. Browser would return 'ERR_SSL_PROTOCOL_ERROR'.

server {
    listen 80;
    listen 443;
    ssl off;
    server_name xxxx.com;

    location / {
        proxy_set_header   X-Forwarded-For $remote_addr;
        proxy_set_header   Host $http_host;
        proxy_pass         "http://0.0.0.0:8090";
    }
 }

问题

能否请您提出重定向HTTPS-> http(反向代理)的最简洁方法?问候

Could you please advise on the cleanest way to redirect https->http(reverse proxy) ? Regards

编辑1

以下配置导致浏览器"ERR_SSL_PROTOCOL_ERROR".

The following config results in a browser "ERR_SSL_PROTOCOL_ERROR".

server {
    listen 80;

    server_name xxxx.com;

    location / {
        proxy_set_header   X-Forwarded-For $remote_addr;
        proxy_set_header   Host $http_host;
        proxy_pass         "http://0.0.0.0:8090";
    }
 }


server {
       listen 443;
       server_name xxxx.com;
       rewrite ^(.*) http://$host$1 permanent;
 }

推荐答案

使用letencrypt获得免费证书,然后使用https或重定向到http是我的解决方案.

Using letsencrypt to get a free certificate and then either use https or redirect to http was the solution for me.

@RichardSmith的积分

Credits to @RichardSmith

这篇关于Nginx重定向https-> http(反向代理)->端口(docker容器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆