我的三级域名无法通过 nginx 作为反向代理正常工作

我的三级域名无法通过 nginx 作为反向代理正常工作

我的网站“staging.my_website.com”的 nginx 配置的一部分,在这种情况下,Nginx 是一个反向代理:

  server {
      listen 80 default_server;
      listen [::]:80 default_server;
      server_name staging.my_website.com;
      return 301 https://$server_name$request_uri;
  }

  server {
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name localhost www.staging.my_website.com;
    return 301 https://staging.my_website.com$request_uri;
  }

  server {
      listen 443 ssl default_server;
      listen [::]:443 ssl default_server;
      server_name staging.my_website.com;

      location / {
        # ...............

        proxy_pass          http://localhost:1234;
        proxy_redirect      http://localhost:1234 https://staging.my_website.com;

它不起作用:

staging.my_website.com show the default page of nginx
htttps://staging.my_website.com -- unavailable

还:

  $ curl -v http://localhost:1234

  * Rebuilt URL to: http://localhost:1234/
  *   Trying 127.0.0.1...
  * Connected to localhost (127.0.0.1) port 1234 (#0)
  > GET / HTTP/1.1
  > Host: localhost:1234
  > User-Agent: curl/7.47.0
  > Accept: */*
  > 
  < HTTP/1.1 301 Moved Permanently
  < server: ......
  < date: .............
  < content-length: 0
  < cache-control: max-age=0, private, must-revalidate
  < location: https://my_website.com/           # why not staging?????
  < 
  * Connection #0 to host localhost left intact

请注意,在“my_website.com” - 一个单独的服务器上 - 一切运行良好。

更新

我重新部署了我的 Web 应用。但是,一切都保持不变。除了这一点:

  # .............
  < location: https://staging.my_website.com/

但和以前一样:

staging.my_website.com -- shows the default page of nginx

htttps://staging.my_website.com -- unavailable

相关内容