反向代理的应用举例:
反向代理服务器对于用户而言,用户并不清楚自己的访问的服务器(网站)是否是真的要访问的网站还是代理的网站,只有反向代理出错或者用户熟悉该网站的一些标签性质的信息时用户才可能意识到自己实际是在访问一个代理服务器。
反向代理服务器往往用于提高内网服务器的安全性,但不局限于此。通过代理不仅隐藏了真实服务器的位置和系统信息,而且往往代理服务器本身的安全性被管理员配置得比较高,因此很难被攻入。比如反向代理服务器位于经过安全加固了的Linux服务器上,去代理一个Windows服务器上的网站,那实际上就降低了那台Windows服务器的安全风险。
# 反向代理其他网站服务器
# proxy reverse setting.
server {
listen port;
server_name domainname(FQDN);
location / {
proxy_pass http://{ipaddress | domainname(FQDN)};
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
# 虚拟主机设置
# vhost setting
server
{
listen port;
server_name {ipaddress | domainname(FQDN)};
index index.html index.htm index.php default.html default.htm default.php; # 根据需要选择顺序
root /web contents path;
include none.conf;
location ~ .*\.(php|php5)?$
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log off;
}
附:httpd.apache.org的官方安全建议(http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#access):
Strictly limiting access is essential if you are using a forward proxy (using the ProxyRequests directive). Otherwise, your server can be used by any client to access arbitrary hosts while hiding his or her true identity. This is dangerous both for your network and for the Internet at large. When using a reverse proxy (using the ProxyPass directive with ProxyRequests Off), access control is less critical because clients can only contact the hosts that you have specifically configured.
严格限制出入站是必不可少的,如果你使用的是正向代理(使用ProxyRequests指令)。则你的服务器可以让使用任何客户端的用户访问任意主机,而他或她的真实身份将被隐藏(客户端都被认为是代理服务器在访问任意主机)。这对于为大型的网络和互联网应用来说是很危险的。
而当使用反向代理(使用的ProxyPass指令ProxyRequests关闭),访问控制是至关重要的,因为客户端只能访问专门配置的反向代理服务器主机。
Nginx如何反向代理网站和设置虚拟主机
原创文章标签 反向代理 nginx反向代理 nginx proxy nginx代理服务器 文章分类 服务器
©著作权归作者所有:来自51CTO博客作者urey_pp的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
使用nginx进行反向代理(配置虚拟主机)
没有写完
使用nginx进行反向代理(配置虚拟主机 -
配置虚拟主机—基于域名的虚拟主机配置、Nginx反向代理、Nginx实现负载均衡笔记
1、配置虚拟主机—基于域名的虚拟主
nginx反向代理 nginx负债均衡 虚拟域名配置 tomcat html