Amazon Lightsail VPS 不支持 Nginx? (Django React 项目部署)
Amazon Lightsail VPS not working with Nginx? (Django React project deployment)
我新注册了 Amazon VPS 服务 Amazon Lightsail。正确设置我的 Django 应用程序、Gunicorn 和 Nginx 后,流量似乎出现了一些问题?
我使用相同的过程在两个不同的 VPS 上设置了相同的 Django 应用程序,都使用 Ubuntu 18。
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' 页面,而第二个显示 (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 Lightsail 在控制面板的 'Networking' 标签下有自己的防火墙。所以不需要自己在Ubuntu中设置ufw
。 Nginx 的欢迎页面根本不显示。完成将域指向 Lightsail 实例的 public IP 后,一切就绪。
我的特殊问题是,由于我所做的设置,Django 需要 SSL 访问。因此,在使用 cerbot 安装 SSL 后,网站就可以访问了。
PS。在完成部署之前禁用 8000 端口是个好主意。
我新注册了 Amazon VPS 服务 Amazon Lightsail。正确设置我的 Django 应用程序、Gunicorn 和 Nginx 后,流量似乎出现了一些问题?
我使用相同的过程在两个不同的 VPS 上设置了相同的 Django 应用程序,都使用 Ubuntu 18。
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' 页面,而第二个显示 (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 Lightsail 在控制面板的 'Networking' 标签下有自己的防火墙。所以不需要自己在Ubuntu中设置ufw
。 Nginx 的欢迎页面根本不显示。完成将域指向 Lightsail 实例的 public IP 后,一切就绪。
我的特殊问题是,由于我所做的设置,Django 需要 SSL 访问。因此,在使用 cerbot 安装 SSL 后,网站就可以访问了。
PS。在完成部署之前禁用 8000 端口是个好主意。