linux_wiki:nginx_http_server

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux_wiki:nginx_http_server [2018/04/09 00:35]
billdozor [Default Config: default.conf]
linux_wiki:nginx_http_server [2019/05/25 23:50] (current)
Line 239: Line 239:
     * CentOS 6<code bash>/etc/init.d/nginx restart</code>     * CentOS 6<code bash>/etc/init.d/nginx restart</code>
     * CentOS 7<code bash>systemctl restart nginx</code>     * CentOS 7<code bash>systemctl restart nginx</code>
 +
 +----
 +
 +===== Example: Reverse Proxy =====
 +
 +Nginx can function as a reverse proxy. This is particularly useful for:
 +  * Accepting connections on secure standard ports and forwarding them to non-secure/standard ports for applications
 +  * Sitting in front of an application server (that might be listening on localhost)
 +  * Load balancing
 +
 +==== Forward to Non Standard Port ====
 +
 +This example accepts connections on standard port 443/tcp and forwards the request to a Java application listening on localhost, port 8080/tcp.
 +<code bash>
 +server {
 +....
 +# Location: Reverse Proxy to Java App
 +    location /myapp/ {
 +      # Forward /myapp/ requests to correct port
 +      proxy_pass http://127.0.0.1:8080/myapp/;
 +
 +      # Additional headers to pass
 +      proxy_set_header        Host            $host;
 +      proxy_set_header        X-Real-IP       $remote_addr;
 +      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
 +    }
 +}
 +</code>
  
 ---- ----
  • linux_wiki/nginx_http_server.1523248507.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)