马哥Linux第二十一周

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
image.png
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
禁止转载,如需转载请通过简信或评论联系作者。