Nginx reverse proxy of static and dynamic separation

We already know what a forward proxy and reverse proxy, this time we will talk about the case of static and dynamic separation of Nginx, and its essence is to use a reverse proxy, specifically with a picture resources on a single server proxy server.
Want to use the proxy is bound to configure a proxy, reverse proxy configuration, you must use the proxy_passcommands to configure.
Open nginx configuration file nginx.conf, add the following configuration in your server web hosting segment:

location ~ \.(jpg|gif|png)$ {
    proxy_pass IP:port;
}

Example:

location ~ \.(jpg|gif|png)$ {
    #         协议://IP地址:端口号(默认是80)
    proxy_pass http://image.itbsl.com;
}

Thoughts?
Led to a reverse proxy server received the backing of the client IP is the IP front-end server, not the client's true IP, how to do?
A: The proxy server by setting the header field, spread to the back-end server to the user's IP.

location ~ \.(jpg|gif|png)$ {
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_pass http://image.itbsl.com;
}

Guess you like

Origin www.cnblogs.com/itbsl/p/11600485.html