Nginx-NO.141.Nginx.1 -Nginx
Posted 仿佛兮若轻云之蔽月,飘飘兮若流风之回雪
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Nginx-NO.141.Nginx.1 -Nginx相关的知识,希望对你有一定的参考价值。
Style:Mac
Series:Java
Since:2018-09-10
End:2018-09-10
Total Hours:1
Degree Of Diffculty:5
Degree Of Mastery:5
Practical Level:5
Desired Goal:5
Archieve Goal:3
Gerneral Evaluation:3
Writer:kingdelee
Related Links:
http://www.cnblogs.com/kingdelee/
2.安装编译参数
实践1:
需求:
tomcat:8081
访问test1.lee.com,通过nginx访问到8081
启动tomcat
vim /etc/hosts
127.0.0.1 test1.lee.com 127.0.0.1 test2.lee.com 127.0.0.1 test3.lee.com
cd /etc/nginx/conf.d
vim test1.conf
server { listen 80; server_name localhost test1.lee.com; location / { proxy_pass http://127.0.0.1:8081; index index.html index.htm; } }
wget test1.lee.com,即可访问到tomcat
大坑:
代理的时候不能加_,否则无法转发过去,会
root@localhost test]# wget test1.lee.com --2018-10-30 17:55:04-- http://test1.lee.com/ Resolving test1.lee.com (test1.lee.com)... 127.0.0.1 Connecting to test1.lee.com (test1.lee.com)|127.0.0.1|:80... connected. HTTP request sent, awaiting response... 400 2018-10-30 17:55:04 ERROR 400: (no description).
正确的打开方式:
upstream test1{ server 127.0.0.1:8081; } server { listen 80; server_name localhost test1.lee.com; location / { proxy_pass http://test1; include proxy_params; index index.html index.htm; } }
以上是关于Nginx-NO.141.Nginx.1 -Nginx的主要内容,如果未能解决你的问题,请参考以下文章