Nginx 常用命令并实现最基本的反向代理
nginx 命令
- 测试配置文件格式是否正确:$ nginx -t
- 启动:nginx
- 重启:nginx -s reload
- 获取nginx进程号: ps -ef|grep nginx
- 停止进程(master): Kill -TERM 22649(进程号)
- 关闭: nginx -s quit (优雅停止)
- 关闭: nginx -s stop (立即停止)
nginx 反向代理(Mac os下)
例如,有两个目录,一个目录下是前端html文件,服务监听的端口是8001;另一个是后端nodejs文件,服务监听的是8000端口。
当浏览器访问 localhost:8888, 然后被nginx 监听后,如果匹配到localhost:8888/...,直接会代理到 8001 端口 html 文件中;如果匹配到localhost:8888/api/...,则会代理到 8000端口的node.js文件中。
打开:/usr/local/etc/nginx/nginx.conf
然后在 nginx 的 http 模块上添加一个 server
server {
listen 8888;
location / {
proxy_pass: http://localhost:8001;
}
location /api/ {
proxy_pass: http://localhost:8000;
proxy_set_header Host $host;
}
}
Nginx 常用命令并实现最基本的反向代理的更多相关文章
- 【Linux】nginx常用命令
相关内容链接 Centos之安装Nginx及注意事项 [nginx]详细配置说明 nginx常用命令 [重新加载配置]sudo nginx -s reload [打开nginx配置]sudo vim ...
- Nginx系列一:正向代理和反向代理、Nginx工作原理、Nginx常用命令和升级、搭建Nginx负载均衡
转自https://www.cnblogs.com/leeSmall/p/9351343.html 仅供个人学习 一.什么是正向代理.什么是反向代理 1. 正向代理,意思是一个位于客户端和原始服务器( ...
- nginx常用命令及简单配置
nginx常用命令 nginx -c /usr/local/nginx/conf/nginx.conf 启动nginx(windows下start nginx); nginx -s quit 停止ng ...
- nginx常用命令汇总
nginx基础命令: sudo nginx // 开启nginx服务器 sudo nginx -s reload // 重启nginx服务器 sudo nginx -s stop // 关闭nginx ...
- Nginx配置二级目录/路径 映射不同的反向代理和规避IP+端口访问
当配置Nginx来映射不同的服务器 可以通过二级路径来反向代理 来解决一个外网端口实现多个服务访问. 配置如下: server { listen ; server_name demo.domai ...
- 记录Nginx常用命令
在此记录下Nginx服务器常用命令(CentOS7.2.Nginx1.14.2环境) 启动Nginx:./usr/sbin/nginx Nginx检查语法:nginx -tc /etc/nginx/n ...
- nginx常用命令参数
命令行参数: 常用命令: -c filename:设置配置文件. -t :不运行,而仅仅测试配置文件.nginx 将检查配置文件的语法的正确性,并尝试打开配置文件中所引用到的文件. -s :传递一个信 ...
- webpack、npm、nginx常用命令
webpack命令:webpack --watch 监听变动并自动打包,简写-wwebpack -p --progress --color 压缩混淆脚本webpack -d 生成映射文件,告知那些模 ...
- Nginx常用命令,解决你日常运维的烦恼
前面,跟大家简单地介绍了负载均衡和Nginx的一些基础配置(Nginx负载均衡配置实例),接下来,跟大家介绍一下Nginx的常用命令,便于日常的运维. 查看原文 停止Nginx的方法 通过之前的学习, ...
随机推荐
- 开源:dotNET.Boilerplate For .net core 开发框架
git地址: https://gitee.com/conan5566linyiling/conan.net dotNET.Boilerplate is an open source applicati ...
- 增量ETL (长周期指标) 优化方案
在日常数据处理过程中避免不了要计算跨长周期数据指标统计需求,类似于如下: 1. 统计每个城市(过去30天)用户浏览次数: 统计每个城市(本年)用户浏览次数: 统计每个城市(历史至今)用户浏览次数: ...
- continue & tag in GO
Go语言中 continue 语句可以结束当前循环,开始下一次的循环迭代过程,仅限在 for 循环内使用,在 continue 语句后添加标签时,表示开始标签对应的循环,例如: package mai ...
- cp复制
将Data文件复制到B目录下: cp -r /home/hp/Data /home/hp/B/
- leetcode No.242 有效的字母异位词 valid-anagram (Python3实现)
题目描述 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的字母异位词. 示例 1: 输入: s = "anagram", t = "nagaram&q ...
- java Random 随机密码
/** * Created by xc on 2019/11/23 * 生成随机密码:6位数字 */public class Test7_4 { public static void main(Str ...
- [Linux]Linux下samba创建共享文件
1. 安装samba服务 yum install -y samba 2. 创建需要共享的目录 在目录/home/xxxx/share xxx为用户名 mkdir share 修改该目录权限(上层文件夹 ...
- 【ARM-Linux开发】Makefile 使用总结
Makefile 使用总结 1. Makefile 简介 Makefile 是和 make 命令一起配合使用的. 很多大型项目的编译都是通过 Makefile 来组织的, 如果没有 Makefile, ...
- 【layui】【jquery】通过layero获取iframe的元素
$(layero).find('iframe').contents().find('#id'); $(layero).find('iframe').contents().find('#jqGridY' ...
- vue中ref在input中详解
当我们在项目中遇见文本输入框的时候,获取时刻输入框中的值 1.v-model <template> <input type="text" v-model=&quo ...