nginx 安装与反向代理测试 under MAC
安装
在 Mac 下可以直接使用 homebrew 安装 nginx
brew search nginx brew install nginx
启动 nginx: sudo nginx,访问 8080 应能看到欢迎界面
nginx -V 查看 nginx 的启动参数,配置文件的位置默认是
反向代理
http {
server {
listen 8080;
location / {
proxy_pass http://127.0.0.1:2014;
}
}
}
负载均衡加反向代理
myapp1 是一组网页的集合,这里作为一个变量
http {
upstream myapp1 {
server srv1.example.com;
server srv2.example.com;
server srv3.example.com;
}
server {
listen 8080;
location / {
proxy_pass http://myapp1;
}
}
}
注意:
1. location 后面的东西是一个 uri 地址,/ 的话表示根目录的请求直接跳转到 myapp1 上,当然 uri 还可以更长一些,比如 /name 之类的,具体怎么替换还要结合 proxy_pass 来处理,这里分为两种情况
If the proxy_pass directive is specified with a URI, then when a request is passed to the server, the part of a normalized request URI matching the location is replaced by a URI specified in the directive:
location /name/ {
proxy_pass http://127.0.0.1/remote/;
}
If proxy_pass is specified without a URI, the request URI is passed to the server in the same form as sent by a client when the original request is processed, or the full normalized request URI is passed when processing the changed URI:
location /some/path/ {
proxy_pass http://127.0.0.1;
}
参考
1. http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass
2. https://www.nginx.com/blog/load-balancing-with-nginx-plus-part2/?_ga=1.269115441.1947437472.1438069067
nginx 安装与反向代理测试 under MAC的更多相关文章
- Nginx 安装以及反向代理配置(windows)
安装 windows 下 Nginx 安装非常简单,下载地址 http://nginx.org/en/download.html. 选择红框这个,下载下来是个 zip 文件,解压.这时我们双击根目录的 ...
- nginx安装,反向代理配置
1.centos 版本 下载最新稳定版 https://www.nginx.com/resources/wiki/start/topics/tutorials/install/# 2.执行语句: ./ ...
- Nginx安装配置&反向代理
使用Nginx作为前端服务能够更快更及时的响应静态页面.js.图片等,当客户端请求访问动态页面时由Nginx的反向代理给Apache处理,Apache处理完再交予Nginx返回给客户端. Nginx更 ...
- Nginx的安装及反向代理设置
因为项目的缘故,接触到了Nginx的安装和反向代理设置,和大家分享下. 一.Nginx的下载.安装cd /homewget http://nginx.org/download/nginx-1.0.5. ...
- Nginx入门教程-简介、安装、反向代理、负载均衡、动静分离使用实例
场景 Nginx入门简介和反向代理.负载均衡.动静分离理解 https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/102790862 Ub ...
- Nginx 部署、反向代理配置、负载均衡
Nginx 部署.反向代理配置.负载均衡 最近我们的angular项目部署,我们采用的的是Nginx,下面对Nginx做一个简单的介绍. 为什么选择Nginx 轻:相比于Apache,同样的web服务 ...
- Nginx介绍与反向代理
Nginx的产生 没有听过Nginx?那么一定听过它的"同行"Apache吧!Nginx同Apache一样都是一种WEB服务器.基于REST架构风格,以统一资源描述符(Unifor ...
- Nginx配置实例-反向代理实例:根据访问的路径跳转到不同端口的服务中
场景 Ubuntu Server 16.04 LTS上怎样安装下载安装Nginx并启动: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/detai ...
- Nginx 七层反向代理
目录 1.代理 2.正向代理 3.反向代理 4.Nginx 反向代理 5.Nginx 反向代理相关指令介绍 ①.listen ②.server_name ③.location ④.proxy_pass ...
随机推荐
- [转]新兵训练营系列课程——平台RPC框架介绍
原文:http://weibo.com/p/1001643875439147097368 课程大纲 1.RPC简介 1.1 什么是RPC 1.2 RPC与其他远程调用方式比较 2.Motan RPC框 ...
- Asp.NET MVC 拍卖网站,拆解【2】 Asp.NET MVC章回,第(1)节
时间和篇幅所限,MVC不会介绍基本的建站过程,请参照博客园技术专题文章传送门 英语足够好的请直接去微asp.net 官网 传送门(强烈推荐,尤其是想使用最新技术的时候更应该直接去官网),本文主要介绍 ...
- 如果下次做模板,我就使用Nvelocity
普通Replace模板做法 很多人在做邮件模板.短信模板的时候,都是使用特殊标识的字符串进行占位,然后在后台代码中进行Replace字符串,如果遇到表格形式的内容,则需要在后台进行遍历数据集合,进行字 ...
- 空间插值文献阅读(Geostatistical approaches for incorporating elevation into the spatial interpolation of rainfall)
空间插值技术应用必读论文---P. Goovaerts, Geostatistical approaches for incorporating elevation into the spatial ...
- 【Android】进入Material Design时代
由于本文引用了大量官方文档.图片资源,以及开源社区的Lib和相关图片资源,因此在转载的时候,务必注明来源,如果使用资源请注明资源的出处,尊重版权,尊重别人的劳动成果,谢谢! Material Desi ...
- Paip.最佳实践-- Buildin variale 内建变量 ,魔术变量,预定义变量,系统常量,系统变量 1
Paip.最佳实践-- Buildin variale 内建变量 ,魔术变量,预定义变量,系统常量,系统变量 1.1.1 C++内建变量(__LINE__).... 1.1.2 ...
- Merge Into
Merge Into [dbo].[Student] S using [10.58.8.224\TEST].[TestDb].[dbo].[Student] T on S.ID=T.ID WHEN M ...
- js程序设计03——面向对象
ECMAScript中有2中属性:数据属性.访问器属性. 数据属性是为了指定某对象的指定key上的一些行为,比如value是否可删除.修改.key可循环遍历等特点.而访问器属性不包含数据值,包含一堆g ...
- asp.net对cookie的操作
创建cookie: HttpCookie cookie = new HttpCookie("CurrentUser"); //创建一个名称为CurrentUser 的cookie对 ...
- 关于多线程与CRITICAL_SECTION的使用
CRITICAL_SECTION 只能针对多线程进行锁定,在同一个线程中,是可以进入很多次的. 同一线程可以多次进入临界区. 在测试程序(多线程同时访问CADOAccess类的对象)中,辅助线程不论是 ...