1.查看安装包
[root@service01 html]# yum list | grep nginx
pcp-pmda-nginx.x86_64 4.3.2-13.el7_9 updates
2.安装epel源
因为没有nginx安装包,所以我们需要安装一个yum源
sudo yum install epel-release
3.安装jenkins
yum install -y nginx
4.启动
systemctl start nginx
5.反代使用
在http下面加上
upstream xxx-api{
server ip:port;
}
在server下面加上
location /xxx-api/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://xxx-api;
}
6.代理使用
stream {
log_format main '[$time_local] $remote_addr $status $bytes_sent $upstream_addr';
server {
access_log logs/mysql.log main;
listen port;
proxy_connect_timeout 8s;
proxy_timeout 24h;
proxy_pass xx.mysql.rds.aliyuncs.com:port;
}
}
7.检测语法是否正确
nginx -t
8.配置生效
nginx -s reload
|