Flask web: 无法通过域名打开网站

Flask web: can not open the site by domain name

我已经使用 Nginx、supervisor 和 gunicorn 在 AWS ubuntu ec2 中部署了我的 flask Web。 一些奇怪的点: (1) 有时我在safari浏览器中可以通过域名访问我的网站,但一段时间后,我无法通过域名访问。按域名(test.com)访问的站点图片如下:

      test.com
parked free, courtesy of GoDaddy.com.

(2) 我可以使用所有浏览器通过 IP 地址访问它。

(3) 有时我试了别的浏览器,可以通过域访问。但是过了一会儿,与(1)相同的问题。 我的设置文件如下:

sudo vim /etc/nginx/sites-available/default

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    # root /var/www/html;

    # Add index.php to the list if you are using PHP
    # index index.html index.htm index.nginx-debian.html;

    server_name test.com; # 
    access_log /var/log/nginx/access.log; 
    error_log /var/log/nginx/error.log;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        # try_files $uri $uri/ =404;
        proxy_pass http://127.0.0.1:8000; 
        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;        
    }
    

    location /static { # 
        alias /home/ubuntu/blog/app/static/;
        expires 30d; # 
        
    }
    
}

sudo vim /etc/supervisor/conf.d/blog.conf

[program:flask-blog-owner]
command=/home/ubuntu/blog/bash.sh
directory=/home/ubuntu/blog
user=root
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true

bash.sh

#! /bin/bash
cd /home/ubuntu/blog
exec gunicorn -w 4 wsgi:app

Godaddy 中的 DNS 信息

记录 最后更新时间 29/10/21 4:35 下午

Type    Name    Value   TTL Actions
A   @   xx.xx.x.x   1/2 Hour    Edit
A   @   Parked  600 seconds Edit
CNAME   www @   1 Hour  Edit
CNAME   _domainconnect  _domainconnect.gd.domaincontrol.com 1 Hour  Edit
NS  @   ns23.domaincontrol.com  1 Hour  
NS  @   ns24.domaincontrol.com  1 Hour  
SOA @   Primary nameserver: ns23.domaincontrol.com. 1 Hour

  

我已经解决了!刚刚在你的godaddy账户的域名设置中删除了Parked value DNS设置。这可能会导致上述问题。