Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Docker Nginx重定向https->;http(反向代理)——>;港口(码头集装箱)_Docker_Nginx_Nginx Reverse Proxy - Fatal编程技术网

Docker Nginx重定向https->;http(反向代理)——>;港口(码头集装箱)

Docker Nginx重定向https->;http(反向代理)——>;港口(码头集装箱),docker,nginx,nginx-reverse-proxy,Docker,Nginx,Nginx Reverse Proxy,上下文 简单设置 将8090公开为网站的docker容器(node,express) nginx conf公开80并将其映射到本地主机8090 问题 我没有付费SSL证书,我希望尝试访问https的最终用户被重定向到http 我试过重定向,重写,下面是一个简单的听。。没有成功。浏览器将返回“ERR\u SSL\u PROTOCOL\u ERROR” server { listen 80; listen 443; ssl off; server_name xxx

上下文

简单设置

  • 将8090公开为网站的docker容器(node,express)
  • nginx conf公开80并将其映射到本地主机8090
问题

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

我试过重定向,重写,下面是一个简单的听。。没有成功。浏览器将返回“ERR\u SSL\u PROTOCOL\u 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(反向代理)的最干净的方法吗?问候

编辑1

以下配置导致浏览器出现“ERR\u SSL\u PROTOCOL\u ERROR”


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


归功于@RichardSmith

您可以尝试通过ngx_stream_core_模块使用TCP重流


@wpercy感谢您的研究,我以前查看并尝试过该解决方案,但无法使其正常工作,请参见编辑1。如果您试图在不启用SSL的情况下将
https
重定向到
http
,则无法,这是不可能的。要使用
https
(甚至重定向它),您需要一个证书。@RichardSmith没有办法顺利重定向最终用户吗?例如[最终用户浏览器https://example.org]->[他被重定向到http://example.org,浏览器在地址栏附近显示不安全标志]?如果我启用SSL(重定向)并放置自签名证书,问题在于最终用户将看到完整的“此站点不安全”chrome错误页面。当用户键入
https
时,预期连接将是安全的,并且您的站点将向浏览器提供有效的证书。lets encrypt不能解决此问题吗?问题已通过lets encrypt解决。谢谢@RichardSmith。
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;
 }
stream {
    server {
        listen 443;
        proxy_pass 127.0.0.1:80;
    }
}