【问题标题】:How can I redirect traffic from Port 80 to Port 443 using UFW?如何使用 UFW 将流量从端口 80 重定向到端口 443?
【发布时间】:2020-07-05 06:55:43
【问题描述】:

我使用 Ubuntu Server 18.04 并希望将流量从端口 80 转发/重定向到端口 443 (https)。

我想这样做,因为我在 NGINX(端口 80)上有 SSL,并且在 Gunicorn 上在端口 443 上运行了一个 Flask 应用程序。我无法发出 NGINX 代理请求,因为该应用程序不在 virtualenv 中。

我希望使用 UFW。我该怎么做?

【问题讨论】:

    标签: nginx https ubuntu-18.04 nat ufw


    【解决方案1】:

    将 http 重定向到 https 流量并不是 ufw 这样的防火墙的目的。

    您应该将NGINX 中的请求重定向如下:

    server {
        listen 80;
    
        server_name example.org;
        return 301 https://example.org$request_uri;
    }
    

    ... 其中 80 是 http 端口,example.org 是您的域,301 表示浏览器可以在其他地方访问该资源。

    【讨论】:

      猜你喜欢
      • 2020-06-06
      • 2019-02-02
      • 2015-08-07
      • 2021-01-20
      • 1970-01-01
      • 2021-05-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多