Q1、配置nginx反向代理,实现api.x.com域名代理本地9001端口
[root@Centos7 ~]# vim /apps/nginx/conf/nginx.conf
http {
...
include "/apps/nginx/conf.d/*.conf";
...
}
[root@Centos7 ~]# vim /apps/nginx/conf.d/web.conf
server_tokens off;
upstream local {
server 127.0.0.1:9001;
}
server {
listen 80;
server_name api.x.com;
location / {
proxy_pass http://local;
}
}
server {
listen 127.0.0.1:9001;
root /data/site1;
index index.html;
access_log logs/api.x.com.access.log;
}
[root@Centos7 ~]# mkdir /data/site1
[root@Centos7 ~]# echo reverse_proxy > /data/site1/index.html
[root@Centos7 ~]# nginx -t
nginx: the configuration file /apps/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /apps/nginx/conf/nginx.conf test is successful
[root@Centos7 ~]# nginx