配置 http 反向代理

Posted fanweisheng

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了配置 http 反向代理相关的知识,希望对你有一定的参考价值。

[root@nginx ~]# cd /etc/nginx/

1

[root@nginx nginx]# cp nginx.conf nginx.conf.bak #备份一个原配置文件

2

[root@nginx nginx]# vim nginx.conf

3

location /

4

proxy_pass     http://192.168.18.201;

5

6

 

 

 

 

 

 

 

 

 

 

 

指令说明:proxy_pass

 

语法:proxy_pass URL

 

默认值:no

 

使用字段:location, location 中的 if 字段 这个指令设置被代理服务器的地址和被映射的 URI,地址可以使用主机名或 IP 加端 口号的形式,例如:proxy_pass http://localhost:8000/uri/;

8.重新加载一下配置文件

 

 

[root@nginx ~]# service nginx reload

 

1  nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

 

2  nginx: configuration file /etc/nginx/nginx.conf test is successful

3  重新载

4  入 nginx:

[确定]

以上是关于配置 http 反向代理的主要内容,如果未能解决你的问题,请参考以下文章

apache2.2 反向代理 配置css js静态文件

Nginx配置,location(路径替换),反向代理配置实战,代理配置

webpack配置proxy反向代理,解决跨域问题

Apache反向代理配置

正向代理/反向代理理解Nginx概述安装及配置详解

nginx反向代理三种模式