简体   繁体   English

Web服务器的防火墙是否应该阻止端口80上的出站HTTP流量?

[英]Should a web server's firewall block outbound HTTP traffic over port 80?

I understand the need for putting a web server in a DMZ and blocking inbound traffic to all ports except 80 and 443. I can also see why you should probably also block most outbound traffic in case the server is compromised. 我理解需要将Web服务器放在DMZ中并阻止除80和443之外的所有端口的入站流量。我还可以看到为什么在服务器受到威胁时您应该也阻止大多数出站流量。

But is it necessary to block outbound HTTP traffic over port 80? 但是有必要阻止端口80上的出站HTTP流量吗? If so, why? 如果是这样,为什么? A lot of web applications these days rely on sending/retrieving data from external web services and APIs, so blocking outbound traffic over port 80 would prevent this capability. 如今,许多Web应用程序依赖于从外部Web服务和API发送/检索数据,因此阻止端口80上的出站流量将阻止此功能。 Is there a security concern that's valid enough to justify this? 是否存在一个足以证明这一点的安全问题?

我能想到的唯一原因是,如果你的机器在某种程度上被远程妥协,那么它将无法在端口80上DDoS另一个网站。但这不是我通常做的事情。

First - I agree with @vartec on throttling "Rather then blocking it, throttle it. Use iptables -m limit" as at least part of the solution. 首先 - 我同意@vartec关于限制“而不是阻止它,限制它。使用iptables -m limit”作为解决方案的至少一部分。

However I can offer another reason to not block port 80 outbound at all times. 但是,我可以提供另一个不在任何时候阻止端口80出站的原因。 If you have automatic security updates turned on the server can't reach out to PPAs over port 80 to initiate a security update. 如果您启用了自动安全更新,则服务器无法通过端口80与PPA联系以启动安全更新。 Thus if you have automatic security updates set up they won't run. 因此,如果您设置了自动安全更新,则它们将无法运行。 On ubuntu auto-security updates are turned on in 14.04 LTS with: 在ubuntu上,自动安全更新在14.04 LTS中打开:

 sudo apt-get install unattended-upgrades update-notifier-common && \
 sudo dpkg-reconfigure -plow unattended-upgrades
 (then select "YES")

More graceful solutions would be ansible scripts opening the port automatically, possibly also modifying an AWS security group rule via the CLI in addition to iptables if you are at AWS. 更优雅的解决方案是自动打开端口的脚本,如果您在AWS,还可以通过CLI修改AWS安全组规则以及iptables。 I prefer modifying my outbound rules temporarily via AWS CLI initiated by a stealth box. 我更喜欢通过隐藏盒启动的AWS CLI临时修改出站规则。 This forces logging the update up in my AWS S3 log buckets but never shows up in the logs on the server itself. 这会强制在我的AWS S3日志存储桶中记录更新,但永远不会显示在服务器本身的日志中。 Further the server that initiates the update doesn't even have to be in the private subnet ACL. 此外,启动更新的服务器甚至不必位于私有子网ACL中。

Maybe do both? 也许两个都做? You have to figure at times an attack is going to relay off an internal IP in your subnet so there is merit to doubling down while preserving the ability to automate backups and security updates. 您必须确定攻击有时会中断您子网中的内部IP,因此在保留自动备份和安全更新的能力的同时,有必要加倍。

I hope this helps. 我希望这有帮助。 If not reply and provide more code examples to be more specific and exact. 如果不回复并提供更多代码示例以更具体和准确。 #staysafe ! #注意安全 !

If the machine is compromised and outbound traffic on port 80 is allowed, it would make it easier for intruders to send back harvested data to themselves. 如果机器受到攻击并且允许端口80上的出站流量,则入侵者可以更容易地将收获的数据发送回自己。 Allowing outbound traffic means you can initiate a connection from your machine to the outside world. 允许出站流量意味着您可以启动从计算机到外部世界的连接。 A better approach would be allowing outbound traffic only to certain web sites/addresses that you trust (ie Microsoft Windows Update, Google reCAPTCHA) rather than any destination in the world. 更好的方法是允许出站流量仅限于您信任的某些网站/地址(即Microsoft Windows Update,Google reCAPTCHA),而不是世界上任何目的地。

Rather then blocking it, throttle it. 而不是阻止它,扼杀它。 Use iptables -m limit. 使用iptables -m limit。

I have several web apps that invoke external web services, so I would say it's a bad idea to block output HTTP traffic. 我有几个调用外部Web服务的Web应用程序,所以我想说阻止输出HTTP流量是个坏主意。 If you're concerned with security, you could block it and allow for only certain destinations. 如果您担心安全性,可以阻止它并仅允许某些目的地。

根据您的SQL版本,您可能会出现SQL Server 2005的证书身份验证超时问题。

what do you mean with blocking outbound traffic over port 80. 阻止端口80上的出站流量是什么意思?

You have two possibilities. 你有两种可能性。 Gernerate Dynamic Rules which allow communication from client to your webserver for this session. Gernerate Dynamic Rules,允许从客户端到您的Web服务器进行此会话的通信。 Search for Stateful firewall rules. 搜索状态防火墙规则。

Or you generally allow established Connections to communicate in and outgoing with each other. 或者,您通常允许已建立的连接相互通信和传出。

If you generally block all outbound traffic over Port 80 your Webserver could not reply to any client. 如果您通常通过端口80阻止所有出站流量,则Web服务器无法回复任何客户端。

The other way around, if your Webserver needs to get some API, eg a jquery library he wont use port 80 as his Port to communicate with the Webserver who holds the API. 反过来说,如果你的Web服务器需要获得一些API,例如一个jquery库,他不会使用端口80作为他的端口与持有API的Web服务器进行通信。

Your Webserver would normally choose a port > 1024 and use it for his request to get the API from the remote Server. 您的Web服务器通常会选择一个> 1024的端口,并将其用于从远程服务器获取API的请求。

So blocking all traffic over port 80 (as your port you connecting from) would not prevent your Server from sending any requests for apis and such things. 因此阻止端口80上的所有流量(作为您连接的端口)不会阻止您的服务器发送任何apis请求等。 because he doesnt use port 80 when he acts as a client. 因为他在担任客户时不使用80端口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM