标签:html serve list location keep 静态 无法访问 com include
Nginx应用场景
反向代理:拦截所有请求,转发到真实的服务器,隐藏真实IP地址(抓包工具也抓取不到真实ip地址),提高安全性
负载均衡:减少单台服务器的压力和故障转移
虚拟主机:将一台主机可以部署多个网站,可以是基于域名的虚拟主机,也可以是基于端口的虚拟主机
http服务器:静态资源服务器
基于域名的虚拟主机配置
http { include mime.types; default_type application/octet-stream; keepalive_timeout 65; ## 当客户端访问nginx 的时候,拦截域名访问为www.xxx.com,监听端口号为80,匹配所有url地址 ## root data/www; 相对于nginx的安装目录 server { listen 80; server_name www.xxx.com; location / { root data/www; index index.html index.htm; } } server { listen 80; server_name bbs.xxx.com; location / { root data/bbs; index index.html index.htm; } } }
基于端口的虚拟主机配置
http { include mime.types; default_type application/octet-stream; keepalive_timeout 65; server { listen 8080; server_name www.xxx.com; location / { root data/www; index index.html index.htm; } } server { listen 8081; server_name www.xxx.com; location / { root data/bbs; index index.html index.htm; } } }
反向代理配置
(一般是nginx单独一台服务器,真实服务器和nginx在同一局域网内,将请求转发到真实服务器上,真实服务器设置为外网无法访问,提高安全性)
http { include mime.types; default_type application/octet-stream; keepalive_timeout 65; server { listen 80; server_name www.irish.com; location / { ##反向代理到内网或者外网地址都可以,推荐使用内网 proxy_pass http://127.0.0.1:8081; } } }
标签:html serve list location keep 静态 无法访问 com include
原文地址:https://www.cnblogs.com/moris5013/p/11133421.html