设为首页 加入收藏

TOP

nginx+tomcat单个域名及多个域名配置(二)
2019-09-17 18:56:21 】 浏览:61
Tags:nginx tomcat 单个 域名 多个 配置
0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }

 上面的配置还包括了访问xxxx.com转向www.xxxx.com的配置,如下:

   server {
        server_name xxxx.com;
        rewrite ^(.*) http://www.xxxx.com$1 permanent;
    }

nginx的基本配置大致就是这样,如果绑定多个域名(不管是一级域名还是二级域名),需配置多个server,你会发现这几个server配置都差不多,主要是更改server_name及proxy_pass指向即可。upstream节点其实就是代理服务的访问路径。

如果此时访问域名,你会发现nginx的配置生效了,只是目前显示的是tomcat的默认界面。nginx的配置基本就这样了,接下来对tomcat做些配置的修改。找到tomcat里的conf/server.xml,注释掉默认的Host配置,添加如下Host配置:

    <Host name="localhost" appBase="E:\tomcat\apache-tomcat-8.0.35-8082\webapps\web" deployOnStartup ="false" autoDeploy="false" unpackWARs="true">
                 <Context path="/"  docBase="E:\tomcat\apache-tomcat-8.0.35-8082\webapps\web" />
                 <Valve   className="org.apache.catalina.valves.AccessLogValve"   
                 directory="logs"     prefix="localhost_access_log"   suffix=".txt"   
                 pattern="%h %l %u %t "%r" %s %b"   />
    </Host> 

以上是windows服务器下的配置,如为linux,只需更改appBase和docBase,指向项目的路径。tomcat的配置也已经完成,重启tomcat,访问域名就指向了tomcat里的项目。

希望能对大家有帮助,如果在使用的过程中遇到什么问题,可以在底下留言。

我的博客即将搬运同步至腾讯云+社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan

 

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇架构设计之防止或缓解雪崩效应 下一篇Struts 2 入门

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目