我得到了一个运行laravel应用程序的aws机器,现在我试图安装beanstalk控制台 。 这就是laravel应用程序的nginxconfiguration文件的样子:
include forge-conf/default/before/*; server { listen 80 default_server; listen [::]:80 default_server; server_name default; root /home/forge/default/public; # FORGE SSL (DO NOT REMOVE!) # ssl_certificate; # ssl_certificate_key; ssl_protocols .. ssl_ciphers .. ssl_prefer_server_ciphers on; ssl_dhparam .. add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; index index.html index.htm index.php; charset utf-8; # FORGE CONFIG (DOT NOT REMOVE!) include forge-conf/default/server/*; location / { try_files $uri $uri/ /index.php?$query_string; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } access_log off; error_log /var/log/nginx/default-error.log error; error_page 404 /index.php; location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; fastcgi_index index.php; include fastcgi_params; } location ~ /\.ht { deny all; } }
这是beanstalk应用程序的nginxconfiguration文件的外观:
server { listen 8080; listen [::]:8080; server_name beanstalk_server; root /home/forge/beanstalk-console/public; index index.html index.htm index.php; location / { try_files $uri $uri/ /index.php?$query_string; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } error_log /var/log/nginx/default-error.log error; error_page 404 /index.php; location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; fastcgi_index index.php; include fastcgi_params; } location ~ /\.ht { deny all; } }
当我尝试命中server-ip:8080 ,出现错误:
server-ip took too long to respond.
我已经确定这不是一个权限的事情,因为我更新了aws实例的入站规则,如下所示:
但仍然没有运气,我知道这是不是一个豆桶控制台本身的问题,B / C,如果我只是简单地切换端口(即,如果使豆茎控制台听80端口,而不是8080,它工作得很好..我也尝试了一个像1515不同的端口,它仍然没有工作)..
我也知道localhost:8080工作正常,B / C运行
wget localhost:8080
确实返回了用于beanstalk的html网站。
有一件事要记住的是,我的aws机器也坐在一个负载平衡器后面,它将端口80上的负载平衡器的http请求转发到机器的端口80 ..但我不认为这会有什么区别
我该怎么办?
我检查了我的访问日志( tail -f /var/log/nginx/access.logtail -f /var/log/nginx/access.log )和错误日志( $ tail -f /var/log/nginx/error.log ),当我试图访问beanstalk时,没有发现任何东西
这是我的netstat命令的输出
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 11997/nginx -g daem tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 11997/nginx -g daem tcp 0 0 10.0.17.158:80 10.0.1.251:19336 ESTABLISHED 11998/nginx: worker tcp 0 0 10.0.17.158:80 10.0.17.87:62074 ESTABLISHED 11998/nginx: worker tcp 0 0 10.0.17.158:80 10.0.17.101:59938 ESTABLISHED 11998/nginx: worker tcp 0 0 10.0.17.158:80 10.0.17.101:60988 ESTABLISHED 11998/nginx: worker tcp 0 0 10.0.17.158:80 10.0.1.21:63633 ESTABLISHED 11998/nginx: worker tcp 0 0 10.0.17.158:80 10.0.1.21:62603 ESTABLISHED 11998/nginx: worker tcp 0 0 10.0.17.158:80 10.0.17.87:63110 ESTABLISHED 11998/nginx: worker tcp 0 0 10.0.17.158:80 10.0.1.251:20344 ESTABLISHED 11998/nginx: worker tcp6 0 0 :::80 :::* LISTEN 11997/nginx -g daem tcp6 0 0 :::8080 :::* LISTEN 11997/nginx -g daem
看来端口8080是不是防火墙..看到这个命令 :
netstat -ntlp | grep LISTEN (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 0.0.0.0:11300 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:587 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 11998/nginx: worker tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 11998/nginx: worker tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN - tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN - tcp6 0 0 :::3306 :::* LISTEN - tcp6 0 0 :::80 :::* LISTEN 11998/nginx: worker tcp6 0 0 :::8080 :::* LISTEN 11998/nginx: worker tcp6 0 0 :::22 :::* LISTEN - tcp6 0 0 :::5432 :::* LISTEN -
我也跑nmap:
nmap 10.0.17.158 Starting Nmap 7.01 ( https://nmap.org ) at 2017-10-11 10:38 EEST Nmap scan report for 10.0.17.158 Host is up (0.000068s latency). Not shown: 995 closed ports PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 3306/tcp open mysql 5432/tcp open postgresql 8080/tcp open http-proxy
基于Shadi的回答,在确认AWS确实将8080端口连接到机器后,问题从iptables变成了问题。
我不知道如何检查端口是否被阻塞或不使用iptables,但是这里有一个允许端口8080的命令:
这是iptables命令,允许从操作系统级别访问端口8080:
sudo iptables -I INPUT 1 -i eth0 -p tcp --dport 8080 -j ACCEPT
(有关iptables命令的参考资料,请参阅这篇优秀的文章 ,直接引用格式是这样的,而且我也将其自己的解释添加到其余部分):
-I INPUT 1:-I标志告诉iptables插入规则。 这与最后追加规则的-A标志不同。 -I标志需要一个链和规则的位置,你要插入新的规则。
在这种情况下,我们将此规则添加为INPUT链的第一条规则。 这将冲击其余的规则。 我们希望这是最重要的,因为它是根本性的,不应该受到后续规则的影响。
-i eth0:如果数据包使用的接口是“eth0”接口(ethernet),则该规则的这个组件匹配。
-p tcp:这只是指定了tcp协议
– dport 8080:我们正在谈论的端口
-j ACCEPT:指定匹配数据包的目标。 在这里,我们告诉iptables,符合上述标准的数据包应该被接受并允许通过。
正如上面的链接中所提到的,你可以简单地运行下面的代码:
sudo iptables -S
这将会输出很多规则,具体取决于您的设置。 要通过追赶,只需运行此命令
$ sudo iptables -S | grep "dport 8080" -A INPUT -i eth0 -p tcp -m tcp --dport 8080 -j ACCEPT
所以从那里你可以立即知道8080端口正在发生什么
只需使用iptables-persistent包:
sudo apt-get update sudo apt-get install iptables-persistent
它会坚持新鲜安装iptables规则,请参阅上面的链接了解更多细节
由于localhost:8080工作,因此来自外部的请求未到达正在侦听该端口8080的服务器。请检查以下内容