niginx相关命令及代理配置
安装
in mac https://www.cnblogs.com/meng1314-shuai/p/8335140.html
Nginx相关命令
mac下启动:
通过brew 安装install 后
sudo cp /usr/local/opt/nginx/*.plist /Library/LaunchDaemons
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
查看安装位置:
ps -ef | grep nginx
启动服务:
sudo nginx
停止服务:
sudo nginx -s stop
语法检查:
sudo nginx -t
重载配置不停服:
sudo nginx -s reload
代理配置
常用关键词:rewrite、proxy_pass
location ^~ /address/ {
proxy_set_header Host xx.sohu.com; #设置header
proxy_set_header Origin http://xx.sohu.com;
#proxy_set_header Cookie "$http_cookie; coder=lxf"; #一般cookie会自动转发,此处可以追加cookie
#proxy_pass http://192.168.1.1:8888/; # hostNow/address/a 转发至 hostOther/a,等效于下面两行,正则的时候不能加/
rewrite /address/(.+)$ /$1 break; #正则匹配
proxy_pass http://192.168.1.1:8888;
}
location ~ (getList|search|folders) { #正则匹配
proxy_set_header Host free-mail-backend-test.sce.sohuno.com;
proxy_set_header Origin http://free-mail-backend-test.sce.sohuno.com;
proxy_pass http://free-mail-backend-test.sce.sohuno.com;
}
其他:
Nginx中不允许if嵌套;
不能设置逻辑运算符(比如啊A&&B),实现逻辑运算只能通过累加计数器或者写到正则里,如下:
location / {
alias /opt/src/app/;
expires 24h;
set $myindex index.html;
#MSIE 6-7 且 XP或Vista系统 才认为是IE6-7
if ($http_user_agent ~* "MSIE [6-7]\.\d.+Windows NT (5\.|6\.0)") {
set $myindex browserGuide.html;
}
index $myindex;
}
参考:
http://www.cnblogs.com/AloneSword/p/3673829.html
http://linux.it.net.cn/e/server/nginx/2014/0709/2704.html
niginx相关命令及代理配置的更多相关文章
- nginx配置, 启动命令, 反向代理配置
2014年1月3日 13:52:07 喜欢这样的风格,干货 http://huoding.com/2013/10/23/290 -----------------下边是我自己的经验(windows)- ...
- niginx代理配置
常用关键词:rewrite.proxy_pass location ^~ /address/ { proxy_set_header Host xx.sohu.com; #设置header proxy_ ...
- Linux网络——配置防火墙的相关命令
Linux网络——配置防火墙的相关命令 摘要:本文主要学习了如何在Linux系统中配置防火墙. iptables命令 iptables准确来讲并不是防火墙,真正的防火墙是运行于系统内核中的netfil ...
- sqlplus 配置方法及相关命令
sqlplus 配置方法及相关命令 1.配置文件 1.1 全局模式什么叫全局模式呢:当我们配置完sqlplus工具加载配置文件后,无论在哪个目录下登陆数据库,您设置[sqlplus提示符样子,在任何目 ...
- linux网络配置相关命令、虚拟网络接口eth0:0
网络接口(interface)是网络硬件设备在操作系统中的表示方法,比如网卡在Linux操作系统中用ethX,是由0开始的正整数,比如eth0.eth1...... ethX.而普通猫和ADSL的接口 ...
- Git配置信息相关命令
查看git所有配置项 $ git config -l or $ git config --list 全局配置用户名邮箱 $ git config --global user.name "yo ...
- angular反向代理配置
Angular-cli 是基于webpack 的一套针对提升angular开发体验的命令行工具. 开发vue的时候,基于webpack的时候当时配置一个反向代理以完全实现前后端分离的体验,既然webp ...
- kafka 相关命令 偏移重置
kafka官方文档 https://kafka.apache.org/documentation.html#quickstart kafka 安装文档 https://www.jianshu.com/ ...
- Windows下Apache服务多个端口反向代理配置
修改\Apache24\conf\httpd.conf: 1.修改安装包地址: Define SRVROOT "/Apache24" 修改为: Define SRVROOT &qu ...
随机推荐
- NX二次开发-UFUN遍历图层UF_LAYER_cycle_by_layer
NX11+VS2013 #include <uf.h> #include <uf_layer.h> #include <uf_ui.h> UF_initialize ...
- Python实现字符串与数组相互转换功能示例
Python实现字符串与数组相互转换功能示例 本文实例讲述了Python实现字符串与数组相互转换功能.分享给大家供大家参考,具体如下: 字符串转数组 str = '1,2,3' arr = s ...
- hexo next主题深度优化(七),cdn加速。
文章目录 注: 正题: 免费cdn 收费cdn 个人博客:https://mmmmmm.me 源码:https://github.com/dataiyangu/dataiyangu.github.io ...
- class3_Entry & Text 输入和文本框
程序总体运行效果图如下; #!/usr/bin/env python # -*- coding:utf-8 -*- # -------------------------------------- ...
- Python3 From Zero——{最初的意识:005~文件和I/O}
一.输出重定向到文件 >>> with open('/home/f/py_script/passwd', 'rt+') as f1: ... print('Hello Dog!', ...
- Python3数据分析与挖掘建模实战✍✍✍
Python3数据分析与挖掘建模实战 Python数据分析简介 Python入门 运行:cmd下"python hello.py" 基本命令: 第三方库 安装 Windows中 p ...
- Neo4j使用简单例子
Neo4j Versions Most of the examples on this page are written with Neo4j 2.0 in mind, so they skip th ...
- Winform打包工具SetupFactory 9 的使用 (转)
写了个WinForm的小程序..以前没打过包..只是直接把Bin里的东西复制出来使用..自己使用是足够.但是发给别人毕竟不太好看(不牛逼)..所以就想着打包.. Vs2012自带的有打包的功能..相信 ...
- --master-data 的作用
Use this option to dump a master replication server to produce a dump file that can be used to set u ...
- Elasticsearch.net一些开发笔记
.net下开发es半年多了,留下些笔记 //https://www.elastic.co/guide/cn/elasticsearch/guide/current/combining-filters. ...