适用于https的Linux Azure App Service裸域不适用于Nginx容器

时间:2019-10-08 02:14:57

标签: azure nginx azure-web-sites azure-web-app-service

我刚刚意识到仅使用https://example.com导航到我的应用程序是行不通的,但是其他URL可以像下面这样正确解析:

http://example.com-> https://www.example.com

http://www.example.com-> https://www.example.com

https://example.com-> ETIMEDOUT

http://www.example.com-> https://www.example.com

关于应用程序的一点点,它是一个运行在Azure的Linux应用服务中的React Web应用程序,我在其中运行nginx容器来为React应用程序提供服务。

我正在为域名提供商使用Namecheap,这是我为域提供的两个相关的重定向DNS记录:

enter image description here

这是我重定向到的azure应用服务的TLS / SSL设置:

enter image description here

现在,我相信这是罪魁祸首,但是我不确定在此发生什么。这是我在nginx容器中的nginx.conf:

http{
    server {
        server_name example.com;
        return 302 $scheme://www.example.com$request_uri;
    }

    server {
        server_name www.example.com;
        root /usr/share/nginx/html;

        location ~* \.(?:manifest|appcache|html?|xml|json)$ {
          expires -1;
          # access_log logs/static.log; # I don't usually include a static log
        }

        location ~* \.(?:css|js)$ {
          try_files $uri =404;
          expires 1y;
          access_log off;
          add_header Cache-Control "public";
        }

        # Any route containing a file extension (e.g. /devicesfile.js)
        location ~ ^.+\..+$ {
          try_files $uri =404;
        }

        # Any route that doesn't have a file extension (e.g. /devices)
        location / {
            try_files $uri $uri/ /index.html;
        }
    }
}

0 个答案:

没有答案