远程服务器上nginx安转与基本操作(ip反向代理转发)
来源:互联网 发布:flex java 做什么的 编辑:程序博客网 时间:2024/06/06 23:17
因为业务系统需求,需要对web服务作nginx代理,在不断的尝试过程中,简单总结了一下常见的nginx代理配置。
下载安装
下载源码
wget http://nginx.org/download/nginx-1.13.4.tar.gz
这是1.2.8版本其他版本自己下载。
安装
#解压tar -zxvf nginx-1.2.8.tar.gz#进入目录cd nginx-1.2.8 配置安转目录./configure --prefix=/usr/local/nginx 编译makemake install
——————————————-分界线开始—————————————-
最近配置的时候报错缺少依赖如下:
./configure: error: the HTTP rewrite module requires the PCRE library.You can either disable the module by using --without-http_rewrite_moduleoption, or install the PCRE library into the system, or build the PCRE librarystatically from the source with nginx by using --with-pcre=<path> option.解决:$ apt-get update$ apt-get install libpcre3 libpcre3-dev./configure: error: the HTTP gzip module requires the zlib library.You can either disable the module by using --without-http_gzip_moduleoption, or install the zlib library into the system, or build the zlib librarystatically from the source with nginx by using --with-zlib=<path> option.解决: $ sudo apt-get install zlib1g-dev
最暴力的解决(可能运行会报错):
$ ./configure --prefix=/usr/local/nginx --without-http_gzip_module
——————————————-分界线结束—————————————-
至此安装完成
验证
启动:
/usr/local/nginx/sbin/nginx
打开浏览器:
输入安装nginx的ip
出现:
Welcome to nginx!
转发配置
vi /usr/local/nginx/conf/nginx.conf
注意两个关键词:location 和proxy_pass
location:就是后缀,proxy_pass:就是转发到的相应的ip及其端口。
如下:
location /{ proxy_pass http://localhost:8080/index.html}#这句话就是说把所有的localhost请求转发到http://localhost:8080/index.htmllocation /test{ proxy_pass http://localhost:8080/test/index.html}#这句话就是说把所有的localhost/test请求转发到http://localhost:8080/test/index.html#注意:不要location 不要写成 /test/ 因为location的pattern识别的路径作为绝对路径。
是不是很简单,对很简单,不过这是nginx最基础的用法,if you want to more , 进入官网吧
0 0
- 远程服务器上nginx安转与基本操作(ip反向代理转发)
- Nginx反向代理转发tomcat
- nginx 转发请求 反向代理
- nginx 转发,反向代理配置实例
- nginx反向代理用做域名转发
- Nginx之反向代理与真实ip地址丢失-yellowcong
- nginx反向代理基本配置
- nginx反向代理基本配置
- Nginx反向代理基本配置
- nginx服务器反向代理tomcat
- nginx反向代理与nat123转发代理的区别和二者安装使用方法和优化配置
- 同一服务器下配置多域名,去掉Tomcat端口号,Nginx反向代理做转发
- nginx安装与http反向代理基本配置
- 通过nginx反向代理,Tomcat获取真实的客户端IP而非服务器IP
- nginx反向代理,node获取真实IP
- Nginx反向代理获取客户端真实IP
- nginx 反向代理取真实IP地址
- Nginx反向代理获取客户端真实IP
- Oracle常用的数据字典
- 动态规划:凑硬币(中级:动态规划思想体会)
- 业务模型;UML类图;数据模型;概念模型;面向对象模型
- Practice6_3_map_sort_by_compareStu
- 快速排序算法(C++实现)
- 远程服务器上nginx安转与基本操作(ip反向代理转发)
- Java线程——两种创建线程的方式
- listen EADDRINUSE 127.0.0.1:3000
- Median of Two Sorted Arrays
- 局域网中抓到NBNS数据包
- 《剑指Offer》替换空格(将字符串中的空格替换为%20)
- mysql 性能-数据类型篇
- uri 与url的区别
- [机器学习] 第一课01笔记