nginx下配置虚拟主机

回复 收藏
我按照您的http://study.lishiming.net/chapter18.html安装的lnmp,但是不知道怎么在nginx下配置虚拟主机
2013-12-26 21:50 举报
已邀请:
0

阿铭 管理员

赞同来自:

每增加一个虚拟主机就是在nginx.conf中增加一段
server {
......
}

具体参考阿铭提供的配置文件。
0

夏夏

赞同来自:

我把我的发一段给你吧
0

夏夏

赞同来自:


log_format  tm.abc.com  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';

####################################################################################
server
  {
    listen       80;
    server_name  tm.abc.com;
#   index  index.shtml;
#    root  /usr/local/tomcat/manage-tomcat-7.0/webapps/manage;
#location ~  (\.html)|(\.png)|(\.ico)|(\.jpg)|(\.gif)|(\.shtml)|(\.css)|(\.js)|(\.jsp)|(\.do)|(\.action)$
location ~ (\.*)$
    {

      proxy_pass http://192.168.20.20:9001;#转向tomcat处理
          include    proxy.conf;
      }

####################################
location /nginx-status {
      #      stub_status on;
            access_log  off;
        }
####################################

   # location ~ .*\(.swf)$ #设定访问静态文件直接读取不经过tomcat
       location ~ .*\.(js|css)?$
    {
      expires      30d;
    }

    location ~ .*\.(js|css)?$
    {
      expires      1h;
    }
  location ~ ^/WEB-INF/*  
    {
      deny all;
    }
#access_log  /home/wwwlogs/access_t.abc.log   tm.abc.com;
#access_log  /home/wwwlogs/access_all.log   tm.abc.com;
}

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: