当前位置:懂科普 >

IT科技

> nginx简单配置反向代理

nginx简单配置反向代理

产品型号:Thinkpad E15

系统版本:centos8

nginx反向代理配置

安装nginx服务

[root@xuegod63 ~]# yum install -y epel-release  #安装yum扩展源,扩展源中有nginx安装包

[root@xuegod63 ~]# yum install -y nginx

我们可以通过 proxy_pass 来配置反向代理

[root@xuegod63 ~]# vim /etc/nginx/nginx.conf

改:

47         location / {

48         }

为:

47         location / {

48             proxy_pass http://www.163.com;

49         }

[root@xuegod63 ~]# systemctl start nginx

查看IP地址

[root@xuegod63 ~]# ifconfig ens33

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.1.63  netmask 255.255.255.0  broadcast 192.168.1.255

访问web服务:http://192.168.1.63/

nginx简单配置反向代理

当我们访问192.168.1.63,就直接跳转到163网站了,说明我们配置的反向代理生效了。

总结:

1、安装nginx服务

[root@xuegod63 ~]# yum install -y epel-release  #安装nginx yum源

[root@xuegod63 ~]# yum install -y nginx

2、我们可以通过 proxy_pass 来配置反向代理

[root@xuegod63 ~]# vim /etc/nginx/nginx.conf

改:

47         location / {

48         }

为:

47         location / {

48             proxy_pass http://www.163.com;

49         }

标签: nginx 配置 代理
  • 文章版权属于文章作者所有,转载请注明 https://dongkepu.com/itkeji/rqlvd.html