Locationhttpd反向代理

Location\httpd\反向代理

参考:http://tengine.taobao.org/nginx_docs/cn/docs/http/ngx_http_core_module.html

测试

在没安装nginx的虚拟机上安装httpd服务

[root@node2 ~]# yum install httpd -y
[root@node2 ~]# chkconfig
[root@node2 ~]#systemctl start httpd.service
[root@node2 ~]#

网页访问192.168.48.102,即可访问到默认的页面,即httpd服务启动成功

[root@node2 ~]# cd /var/www
[root@node2 ~]#ls
[root@node2 ~]#
[root@node2 ~]#vim index.html
from 192.168.48.102...

[root@node2 ~]#
浏览器访问192.168.48.102
from 192.168.48.102...

反向代理

配置nginx.conf文件

server {
        listen       80;
        server_name     www.123.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;  #以html的方式显示
            index  index.html index.htm;  #转发到index.html或index.htm
                   }
        location /test {
            proxy_pass http://192.168.48.102/;  #地址后面带/表示只访问当前目录,不拼接 /test
        }
   }

Original: https://www.cnblogs.com/Boyka1/p/15366193.html
Author: 程胥员
Title: Locationhttpd反向代理

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/598522/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球