1.centos 版本

下载最新稳定版 https://www.nginx.com/resources/wiki/start/topics/tutorials/install/#

2.执行语句:

./configure
make
sudo make install

如碰到./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library 问题,则执行

yum install pcre
yum install pcre-devel

3.在安装目录下配置,本机是/usr/local/nginx/conf/nginx.conf。

配置使用端口 listen 8081(默认80)

4.测试配置文件是否可用

/usr/local/nginx/sbin/nginx -t

5.启动

/usr/local/nginx/sbin/nginx

6.在浏览器中访问

其它常用命令:

/usr/local/webserver/nginx/sbin/nginx -s reload            # 重新载入配置文件
/usr/local/webserver/nginx/sbin/nginx -s reopen # 重启 Nginx
/usr/local/webserver/nginx/sbin/nginx -s stop # 停止 Nginx

配置反向代理

需求:同一服务器中同一个tomcat下不同资源包之间的互通。

nginx 端口:8081

tomcat 端口:80

nginx 配置文件中

server下location配置如下

        location / {
proxy_pass http://127.0.0.1:80/;
} location /resource1 {
rewrite /resource1/(.*) /resource2/$ break;
proxy_pass http://127.0.0.1:80/;
}

结果:

127.0.0.1:8081/resouce1/* =》 实际获取的资源是是127.0.0.1:8081/resouce2/*

nginx安装,反向代理配置的更多相关文章

  1. nginx实现反向代理 配置多域名以及多端口号

    多个服务部署在同一个服务器,使用不同的端口. 一.思考过程 如果不想带上端口号,就只能访问 80 或 443 端口. 可以用过二级目录区分服务,通过反向代理转发到不同的 Server. 可以用过子域名 ...

  2. Nginx之反向代理配置(二)

    前文我们聊了Nginx的防盗链.反向代理以及开启nginx代理缓存,回顾请参考https://www.cnblogs.com/qiuhom-1874/p/12417130.html:今天我们继续说ng ...

  3. linux 安装 nginx 及反向代理配置

    Nginx ("engine x") 是一个高性能的HTTP和反向代理服务器,以下为Linux centos平台下安装nginx并配置反向代理的过程(采用源码安装的方式) 一:安装 ...

  4. Nginx之反向代理配置(一)

    前文我们聊了下Nginx作为web服务器配置https.日志模块的常用配置.rewrite模块重写用户请求的url,回顾请参考https://www.cnblogs.com/qiuhom-1874/p ...

  5. nginx 安装及代理配置。

    新建etc/yum.repos.d/nginx.repo文件,添加以下内容:[nginx] name=nginx repo baseurl=http://nginx.org/packages/cent ...

  6. Nginx 安装以及反向代理配置(windows)

    安装 windows 下 Nginx 安装非常简单,下载地址 http://nginx.org/en/download.html. 选择红框这个,下载下来是个 zip 文件,解压.这时我们双击根目录的 ...

  7. 在ubuntu上面配置nginx实现反向代理和负载均衡

    上一篇文章(http://www.cnblogs.com/chenxizhang/p/4684260.html),我做了一个实验,就是利用Visual Studio,基于Nancy框架,开发了一个自托 ...

  8. nginx反向代理配置及优化

    nginx反向代理配置及优化前言: 由于服务器apache抗不住目前的并发.加上前端squid配置后,问题依然无法解决.而页面程序大部分是动态.无法使用fastcgi来处理.因此想使用nginx做为反 ...

  9. 安装nginx 做反向代理

    nginx反向代理配置实例(前nginx+后apache)Nginx ("engine x") 是一个高性能的 HTTP 和反向代理服务器,也是一个 IMAP/POP3/SMTP ...

  10. docker配置nginx做反向代理管理tomcat应用

    由于业务开始复杂,单一tomcat已经不足以满足业务需求,多tomcat部署起来不方便而且面临域名解析问题,因此开始增加反向代理,由于docker的易用性,便使用docker管理各个应用. docke ...

随机推荐

  1. POJ 1117 Pairs of Integers

    Pairs of Integers Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4133 Accepted: 1062 Des ...

  2. 自定义容器启动脚本报错:exec user process caused "no such file or directory"

    创建容器起不来,一直是restarting状态,查看容器的报错日志如下: standard_init_linux.go:178: exec user process caused "no s ...

  3. Spark ML包,数据挖掘示例数据Affairs

    1.数据字段解释 affairs:一年来婚外情的频率   gender:性别   age:年龄   yearsmarried:婚龄   children:是否有小孩   religiousness:宗 ...

  4. Spring Boot 利用插件构造QueryDSL语句时报错:You need to run build with JDK or have tools.jar on the classpath.If this occur....

    You need to run build with JDK or have tools.jar on the classpath.If this occures during eclipse bui ...

  5. WF的简单使用

    WWF(Windows Workflow Foundation):是微软提供的工作流技术,工作流就是对工作流程的规范和抽象.主要有三个部分Activity(活动).Runtime(工作流运行时)和To ...

  6. POJ-1088 滑雪 (记忆化搜索,dp)

    滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 86318 Accepted: 32289 Description Mich ...

  7. FZU 2092 收集水晶(记忆化搜索)

    Problem 2092 收集水晶 Accept: 101 Submit: 439 Time Limit: 5000 mSec Memory Limit : 32768 KB Problem Desc ...

  8. 三维重建项目:Photo Tourism: Exploring Photo Collections in 3D

    项目地址:http://phototour.cs.washington.edu/ Photo Tourism是华盛顿大学的SFM重建的过程 Paper:Photo Tourism: Exploring ...

  9. Python面向对象:继承和多态

    继承与多态简介: 继承可以把父类的所有功能都直接拿过来,这样就不必重零做起,子类只需要新增自己特有的方法,也可以把父类不适合的方法覆盖重写. 动态语言的鸭子类型特点决定了继承不像静态语言那样是必须的. ...

  10. $obj

    <?php $obj = new stdClass(); for($w=0; $w<10; $w++){ $obj->$w= $w.'w'; $str = $w.'we'; $obj ...