Nginx
安装nginx
使用docker安装nginx
docker pull nginx
基本用途
正向代理
客户端中配置代理服务器
反向代理
负载均衡
部署多个服务器,将请求分发到多个服务
动静分离
配置文件
nginx配置文件由三部分组成。
全局块
从配置文件开始到events块的内容,主要会设置一些影响nginx服务器整体运行的配置指令。
worker_processes 1 可支持的并发处理器
events块
影响nginx服务器和用户的网络连接
worker_connnection 1024 支持的最大连接数
http块
- http全局块
- server块
nginx配置实例
反向代理
http {
server {
listen 88;
server_name localhost;
# 代理静态页面
location ^~/haiou-client/ {
index index.html;
alias /opt/haiou-client/;
}
# 代理后台服务1
location ^~/haiou-server/ {
proxy_pass http://10.73.32.3:8889/haiou-server/;
proxy_set_header X-Forwarded-For $remote_addr;
}
# 代理后台服务2
location ^~/haioubigdata-server/ {
proxy_pass http://10.73.32.3:7889/haioubigdata-server/;
proxy_set_header X-Forwarded-For $remote_addr;
}
}
}