Recipe 10.2 Preventing Your Proxy Server from Being Used as an Open Mail Relay
Problem
If your Apache server is set up to operate as a
proxy, it is possible for it to be used
as a mail relay unless precautions are taken. This means that your
system may be functioning as an "open
relay" even though your mail server software is
actually securely configured.
Solution
Use mod_rewrite to forbid proxy requests to port
25 (SMTP):
<Directory proxy:*>
RewriteEngine On
RewriteRule "^proxy:[a-z]*://[^/]*:25(/|$)" "-" [F,NC,L]
</Directory>
Discussion
To use the Apache proxy as an SMTP relay is fairly trivial, but then so
is preventing it. The solution simply tells the server to respond
with a 403 Forbidden to any attempts to use
it to proxy to a remote mail server (port 25). Other ports, such as
HTTP
(port 80), HTTPS
(port 443), and FTP
(ports 20 and 21),
which are commonly permitted proxy access, will not be affected.
See Also
|