发布网友 发布时间:2022-02-26 21:18
共2个回答
懂视网 时间:2022-02-27 01:40
产品型号: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
inet 192.168.1.63 netmask 255.255.255.0 broadcast 192.168.1.255
访问web服务:http://192.168.1.63/
当我们访问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 }
热心网友 时间:2022-02-26 22:48
方法/步骤
关闭防火墙与SELinux
输入命令:
service iptables stop
setenforce 0
安装编译环境
输入命令:yum install gcc*
安装nginx
切换到nginx源码包存放位置
输入命令:
tar -zxvf nginx-1.6.2.tar.gz
./configure
make
make install
4
配置反向代理
输入命令:
vim /usr/local/nginx/conf/nginx.conf
找到server{***}字段,注释掉,然后自定义该字段。
示例:
server{
listen 80;
server_name 反向代理的域名或ip;
location / {
proxy_pass http://****; //代理指向的服务器
}
}