Nginx多域名映射到对应不同tomcat的nginx.conf配置详解

废话不多说,直接上干货,下面是一个完整的nginx.conf的配置信息:

user nginx;
worker_processes  1;

error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log  notice;
#error_log /var/log/nginx/error.log  info;

pid       /var/run/nginx.pid;

events {
   worker_connections  1024;
}

http {
   include      /etc/nginx/mime.types;
   default_type  application/octet-stream;

   log_format  main  '$remote_addr -$remote_user [$time_local] "$request" '
                     '$status $body_bytes_sent "$http_referer" '
                     '"$http_user_agent" "$http_x_forwarded_for"';

   access_log /var/log/nginx/access.log  main;

   sendfile       on;
   #tcp_nopush    on;

   #keepalive_timeout  0;
   keepalive_timeout  65;

   #gzip  on;

    # Loadmodular configuration files from the /etc/nginx/conf.ddirectory.
    # Seehttp://nginx.org/en/docs/ngx_core_module.html#include
    # for moreinformation.
    include/etc/nginx/conf.d/*.conf;

    upstreamdruid {
       server 127.0.0.1:8090;
   }

upstream yunbang {
       server 127.0.0.1:8091;
    }

    upstreamsanji {
       server 127.0.0.1:8090;
    }

    server{
       listen      80;
       server_name  www.druid.com druid.commonitor.druid.com;
       root  /usr/local/tomcat7-big/webapps;
       location / {
         proxy_pass http://druid;
         proxy_set_header  Host   $host;
         proxy_set_header  X-Real-IP   $remote_addr;
         proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
       }
    }

    server{
       listen      80;
       server_name  www.yunbang.com yunbang.com;
       root  /usr/local/tomcat7-yun/webapps;
       location / {
         proxy_pass http://yunbang;
         proxy_set_header  Host   $host;
         proxy_set_header  X-Real-IP   $remote_addr;
         proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
       }
    }
    server{
       listen      80;
       server_name  www.sanji.com sanji.com;
        root  /usr/local/tomcat7-big/webapps;
阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/LiuXingSiYe/article/details/49942925
文章标签: linux nginx tomcat
个人分类: 运维&服务器
上一篇tomcat多域名绑定之server.xml配置
下一篇AWS免费云主机之如何使用putty登录
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭