美文网首页
马哥Linux第二十一周

马哥Linux第二十一周

作者: Liang_JC | 来源:发表于2020-07-10 15:12 被阅读0次

    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

    相关文章

      网友评论

          本文标题:马哥Linux第二十一周

          本文链接:https://www.haomeiwen.com/subject/xvricktx.html