Nginx 配置文件:
所在目录:
nginx/conf/nginx.conf
配置文件中的内容 (包含三部分内容)
(1)全局块:配置服务器整体运行的配置指令 比如 worker_processes 1;处理并发数的配置
(2)events 块:影响 Nginx 服务器与用户的网络连接 比如 worker_connections 1024; 支持的最大连接数为 1024
(3)http 块 还包含两部分: http 全局块 server 块
Nginx 配置实例-反向代理实例
将nginx地址配置在本地host:
192.168.17.129 www.jym.com
在 nginx 进行请求转发的配置(反向代理配置)
server {
listen 80;
server_name 192.168.17.129;
location / {
root html;
proxy_pass http://127.0.0.1:8080
index index.html index.htm;
}
}
启动nginx服务器的tomcat 与nginx,访问www.jym.com
Nignx 反向代理实例二(通过反向代理,url输入不同的地址跳转不同的tomcat):
实现效果 使用 nginx 反向代理,根据访问的路径跳转到不同端口的服务中 nginx 监听端口为 9001,
准备工作:
(1)准备两个 tomcat 服务器,一个 8080 端口,一个 8081 端口
(2)创建文件夹和测试页面
具体配置:
server {
listen 9001;
server_name 192.168.17.129;
location ~/edu/ {
root html;
proxy_pass http://127.0.0.1:8080
index index.html index.htm;
}
location ~/vod/ {
root html;
proxy_pass http://127.0.0.1:8081
index index.html index.htm;
}
}
测试: