]> gitweb.factorcode.org Git - factor.git/blob - basis/http/server/remapping/remapping-docs.factor
aa38087766d062f6e0ee4b42ff137216e344c3e4
[factor.git] / basis / http / server / remapping / remapping-docs.factor
1 USING: help.markup help.syntax ;
2 IN: http.server.remapping
3
4 HELP: port-remapping
5 { $var-description "An assoc mapping port numbers that the HTTP server listens on to external port numbers presented to the user." } ;
6
7 ARTICLE: "http.server.remapping" "HTTP server port remapping"
8 "On Unix systems, non-root processes cannot bind to sockets on port numbers under 1024. Since running an HTTP server as root is a potential security risk, a typical setup runs an HTTP server under an ordinary user account, set up to listen on a higher port number such as 8080. Then, the HTTP port is redirected to 8080. On Linux, this might be done using commands such as the following:"
9 { $code
10     "echo 1 > /proc/sys/net/ipv4/ip_forward"
11     "iptables -t nat -F"
12     "iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j DNAT --to :8443"
13     "iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j DNAT --to :8080"
14 }
15 "However, the HTTP server is unaware of the forwarding, and still believes that it is listening on port 8080 and 8443, respectively. This can be a problem if a responder wishes to redirect the user to a secure page; they will be sent to port 8443 and not 443 as one would expect."
16 $nl
17 "The " { $vocab-link "http.server.remapping" } " vocabulary defines a variable which may store an assoc of port mappings:"
18 { $subsection port-remapping }
19 "For example, with the above setup, we would set it as follows:"
20 { $code
21     "{ { 8080 80 } { 8443 443 } } port-remapping set-global"
22 } ;
23
24 ABOUT: "http.server.remapping"