1 nginx iptables web-server centos
我的 Nginx 有一个非常奇怪的问题,我无法从浏览器访问它。
我已经在我的计算机上安装了 CentOS 7 虚拟机,并安装并配置了 Nginx、PHP-FPM 和 MariaDB。
Nginx的配置如下:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /path/to/www
index index.php;
try_files $uri $uri/ /index.php?$args;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
try_files $uri $uri/ = 404;
root /path/to/www/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
Run Code Online (Sandbox Code Playgroud)
我还使用以下规则配置了 Iptables:
INPUT_ZONES all -- anywhere anywhere
ACCEPT icmp -- anywhere anywhere
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
ACCEPT tcp -- anywhere anywhere tcp dpt:http
ACCEPT tcp -- anywhere anywhere tcp dpt:https
ACCEPT tcp -- anywhere anywhere tcp dpt:mysql
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
OUTPUT_direct all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere tcp spt:http
ACCEPT tcp -- anywhere anywhere tcp spt:https
ACCEPT tcp -- anywhere anywhere tcp spt:mysql
Run Code Online (Sandbox Code Playgroud)
而且我也决定暂时禁用SELinux...
最后,在执行“tcpdump port 80”时,我在尝试访问 Web 服务器时收到此消息:
listening on enp0s3, link-type EN10MB (Ethernet), capture size 65535 bytes
19:39:51.574889 IP 192.168.56.1.59338 > 192.168.56.101.http: Flags [S], seq 2033938019, win 65535, options [mss 1460,nop,wscale 4,nop,nop,TS val 551897257 ecr 0,sackOK,eol], length 0
Run Code Online (Sandbox Code Playgroud)
我的电脑网页浏览器说它无法连接到指定的服务器...
你知道什么可能导致这个问题吗?我错过了什么 ?
很抱歉收到这么长的消息,但我真的不知道现在该怎么办..
谢谢
您的防火墙规则拒绝所有传入流量。
您尝试通过手动附加规则以允许 HTTP、HTTPS 和 MySQL 连接来解决此问题,但这不起作用,因为它们已被先前的规则拒绝。
此外,您的系统正在运行 firewalld。
要解决此问题,您应该使用 firewalld 来管理您的防火墙规则。
例如:
firewall-cmd --add-service=http
firewall-cmd --add-service=https
firewall-cmd --add-service=mysql
Run Code Online (Sandbox Code Playgroud)
要使它们持久化,请运行:
firewall-cmd --runtime-to-permanent
Run Code Online (Sandbox Code Playgroud)
(这最后一项要求您至少更新到 CentOS 7.1。)
归档时间: |
|
查看次数: |
4723 次 |
最近记录: |