背景:
學習docker時安裝nginx后,在服務器中可以用curl可以訪問,瀏覽器中訪問不了。
現象:
服務器本地訪問
[root@like ~]# curl localhost:80 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> <style> html { color-scheme: light dark; } body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html>
瀏覽器訪問時為:
解決辦法:
1、添加新的防火牆規則,開放對應的端口
2、iptables 問題,設置將數據轉發到本機的其他網卡設備上就可以了。命令為:iptables -P FORWARD ACCEPT