linux 中 nginx配置

1、nginx中include的使用

在/usr/local/nginx/conf/nginx.conf中可以使用include去加载其他配置文件:

例如:include vhost/*.conf;

加载同目录下的   vhost/*.conf文件

  

2、配置虚拟域名访问

客户机需在hosts文件中添加:

ip域名对应关系如:140.143.2.XX.129   image.test

window中hosts位置:C:\Windows\System32\drivers\etc

 nginx中conf文件对应的域名配置如下:

   1.1访问文件,image.test.conf配置

 

  访问 测试下:

    

  1.2、当添加上:autoindex on时,等于建立了文件索引,可以访问目录,

 

    访问示例如下

   

 autoindex off时,访问目录示例如下:

 2、访问tomcat, www.test.conf配置

 

nginx.conf中负载均衡配置,http://test跳转到以下地址

 访问测试如下:

  

猜你喜欢

转载自www.cnblogs.com/pinghengxing/p/9445224.html