Amazon Lightsail VPS不能与Nginx一起使用吗? (Django React项目部署)

问题描述 投票:0回答:1

我已经向Amazon VPS服务Amazon Lightsail新注册。正确设置我的Django应用,Gunicorn和Nginx之后,流量似乎有问题吗?

[我在Ubuntu 18上使用相同的过程在两个不同的VPS上设置了相同的Django应用程序,]

IP无法在AWS(13.124.94.92)上运行:

~# ping -c3 13.124.94.92
PING 13.124.94.92 (13.124.94.92) 56(84) bytes of data.

--- 13.124.94.92 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2044ms

[IP在另一个VPS Ubuntu 18中运行正常(5.63.152.4):

~# ping -c3 5.63.152.4
PING 5.63.152.4 (5.63.152.4) 56(84) bytes of data.
64 bytes from 5.63.152.4: icmp_seq=1 ttl=64 time=0.063 ms
64 bytes from 5.63.152.4: icmp_seq=2 ttl=64 time=0.108 ms
64 bytes from 5.63.152.4: icmp_seq=3 ttl=64 time=0.082 ms

--- 5.63.152.4 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2043ms
rtt min/avg/max/mdev = 0.063/0.084/0.108/0.019 ms

第一个IP没有显示'Welcome to Nginx'页面,而第二个IP却显示(http://5.63.152.4/

我不确定该从哪里开始调试...我对iptables有点弄弄,因为mosh无法正常工作。请帮忙!谢谢!!

附加信息:

启用防火墙

~$  sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
60000:61000/udp            ALLOW       Anywhere                  
Nginx Full                 ALLOW       Anywhere                  
OpenSSH                    ALLOW       Anywhere                  
mosh                       ALLOW       Anywhere                  
5432/tcp                   ALLOW       Anywhere                  
60000:61000/udp (v6)       ALLOW       Anywhere (v6)             
Nginx Full (v6)            ALLOW       Anywhere (v6)             
OpenSSH (v6)               ALLOW       Anywhere (v6)             
mosh (v6)                  ALLOW       Anywhere (v6)             
5432/tcp (v6)              ALLOW       Anywhere (v6)       

nginx状态

~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

/ etc / nginx / {站点可用,启用站点} / myproject

server {
    listen 80;
    server_name server_domain_or_IP;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/sammy/myprojectdir;
    }
    location /media/ {
        root /home/sammy/myprojectdir;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }
}

独角兽状态

~$ sudo systemctl status gunicorn
● gunicorn.service - gunicorn daemon
   Loaded: loaded (/etc/systemd/system/gunicorn.service; disabled; vendor preset: enabled)
   Active: active (running) since Fri 2020-05-01 06:14:48 UTC; 1h 17min ago
 Main PID: 14512 (gunicorn)
    Tasks: 4 (limit: 517)
   CGroup: /system.slice/gunicorn.service
...

我已经向Amazon VPS服务Amazon Lightsail新注册。正确设置我的Django应用程序Gunicorn和Nginx之后,流量似乎有问题吗?我设置了相同的Django ...

django nginx deployment server vps
1个回答
0
投票

对于其他像我这样的新手:

问题已解决... Amazon Lightsail在控制面板上的“网络”标签下有自己的防火墙。因此,无需在Ubuntu中自行设置ufw。 Nginx的欢迎页面根本不会显示。将您的域指向Lightsail实例的公共IP后,就一切就绪。

© www.soinside.com 2019 - 2024. All rights reserved.