amazon-web-services - 无法在 ubuntu AWS EC2 服务器上访问 nginx
问题描述
我正在尝试启动一个 Python 网络应用程序,就像我通常做的一样(并不是说我完全知道我在做什么)。通常,当我在服务器上运行 nginx 并在浏览器中访问 IP 时,我会看到“错误网关”。无论出于何种原因,我现在只是超时。
编辑:我期待一个坏网关,我什么也没得到
提前致谢,
我没有对默认配置文件做任何事情......我etc/nginx/sites-available/default
看起来像这样
server {
listen 80;
server_name ec2-52-36-167-131.us-west-2.compute.amazonaws.com;
access_log /var/log/nginx/test.log;
location / {
proxy_pass http://127.0.0.1:8000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
sudo service nginx status
看起来像这样
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-06-19 02:06:09 UTC; 8s ago
Docs: man:nginx(8)
Process: 9149 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 9161 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 9152 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 9162 (nginx)
Tasks: 2 (limit: 1152)
CGroup: /system.slice/nginx.service
├─9162 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
└─9163 nginx: worker process
Jun 19 02:06:09 ip-172-31-25-6 systemd[1]: Stopped A high performance web server and a reverse proxy server.
Jun 19 02:06:09 ip-172-31-25-6 systemd[1]: Starting A high performance web server and a reverse proxy server...
Jun 19 02:06:09 ip-172-31-25-6 systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Jun 19 02:06:09 ip-172-31-25-6 systemd[1]: Started A high performance web server and a reverse proxy server.
当我curl -I ec2-52-36-167-131.us-west-2.compute.amazonaws.com
在服务器上时,我得到了我期望的坏网关,但在我的本地机器上我得到了超时。
解决方案
解决了,这是 AWS 安全组中的一个问题。
推荐阅读
- r - get_acs() 在提取人口普查块组时无法从 2012 年或之前的调查中获取数据
- php - 使用 CodeIgniter 通过网站将文件从 FTP 服务器下载到客户端计算机
- substring - 如何在python 3中的某个文本之前找到字符串的最短子串
- python - 根据唯一值列表拆分列表
- python-3.x - 使用 Python 捕获标准输出并写入现有进程的标准输入
- java - 测试清单
- > 包含任何顺序的相同项目
- java - 将测试容器与 Java 模块中的代码一起使用
- assembly - 您可以在 add 指令中使用偏移量吗?
- java - 为什么我在方法调用时收到此空错误?
- linux - Linux 4.14 中的 NETLINK_NFLOG 支持