docker中的nginx如何禁用http重定向到https

Ram*_*san 5 curl nginx docker

我正在尝试使用 docker 容器在 digitalocean 中部署 Meteor 应用程序。我已经在两个 Web docker 和一个 nginx docker 中完成了设置应用程序。我分叉了这个镜像仓库来构建 docker。你可以在lib目录下看到nginx配置。这里 nginx 配置了 SSL 并向 web docker 请求。我在生成 IP 地址的 SSL 证书时遇到了一些问题。应用程序正在开发中,因此计划暂时删除 SSL。所以改变了Nginx配置。

daemon off;
error_log /dev/stdout notice;
worker_processes  1;

events {
    worker_connections  4096;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    upstream site{
      server backend1:80;
      server backend2:80;
    }

    sendfile        on;
    keepalive_timeout  65;

    gzip  on;

    server {
        listen              80 default_server;
        server_name         mup-ssl; //tried mup-ssl; and _;
        client_max_body_size 10M;


        location / {
          proxy_pass http://site/;
          proxy_redirect      off;
          proxy_set_header    Host              $host;
          proxy_set_header    X-Real-IP         $remote_addr;
          proxy_set_header    X-Forwarded-For   $proxy_add_x_forwarded_for;
          proxy_set_header    X-Forwarded-Proto $scheme;

          proxy_http_version 1.1;
          proxy_set_header    Upgrade           $http_upgrade;
          proxy_set_header    Connection        "upgrade";

          #
          # Specific for comet or long running HTTP requests, don't buffer up the
          # response from origin servers but send them directly to the client.
          #
          proxy_buffering     off;

          #
          # Bump the timeout's so someting sensible so our connections don't
          # disconnect automatically. We've set it to 12 hours.
          #
          proxy_connect_timeout 43200000;
          proxy_read_timeout    43200000;
          proxy_send_timeout    43200000;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

问题是每当我点击http://xxx.xxx.xxx.xx.xx浏览器时它都会重定向到https://xxx.xxx.xxx.xx.xx. 我该如何禁用https?重定向。

卷曲响应:

curl -i http://xxx.xxx.xx.xx
HTTP/1.1 302 Moved Temporarily
Server: nginx/1.8.0
Date: Tue, 05 Apr 2016 18:09:11 GMT
Transfer-Encoding: chunked
Connection: keep-alive
Location: https://xxx.xxx.xx.xx/

curl -i https://xxx.xxx.xx.xx/
curl: (7) Failed to connect to xxx.xxx.xx.xx port 443: Connection refused
Run Code Online (Sandbox Code Playgroud)

小智 0

在您的 docker-compose 中,仅添加: HTTPS_METHOD=noredirect 在环境中。像这样

service:
    container_name: name
    restart: always
    environment:
      - HTTPS_METHOD=noredirect
    env_file:
      - .env
Run Code Online (Sandbox Code Playgroud)