just a simple example, for more information -> http://nginx.org/en/docs/.
1.vi /etc/yum.repos.d/nginx.repo
2. find repo from http://nginx.org/packages, choose version according to your system. save it.
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/[OS(for example:centos)]/$releasever/$basearch/
gpgcheck=0
enabled=1
3.yum install nginx
(yum update)
4.config nginx
u can edit nginx.conf directly or use "include" in nginx.conf
(1)root
A location context can contain directives that define how to resolve a request – either serve a static file or pass the request to a proxied server.
(2)proxy_pass
The proxy_pass directive passes the request to the proxied server accessed with the configured URL. The response from the proxied server is then passed back to the client.
(3)proxy_set_header (NGINX Reverse Proxy)
By default, NGINX redefines two header fields in proxied requests, “Host” and “Connection”,
and eliminates the header fields whose values are empty strings. “Host” is set to the $proxy_host variable, and “Connection” is set to close:
proxy_set_header Host $proxy_host;
proxy_set_header Connection close;
To change these setting, as well as modify other header fields, use the "proxy_set_header" directive.
This directive can be specified in a location or higher.
It can also be specified in a particular server context or in the http block
server {
listen 80;
server_name www.system-in-motion.com;
root [location context];
location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080/;
}
}