美文网首页
Nginx + Tomcat 配置

Nginx + Tomcat 配置

作者: 浮云骑士_ | 来源:发表于2017-03-06 16:08 被阅读0次

这里使用Nginx解析域名,做出域名到Tomcat的映射

不多说 贴代码

Nginx

在http下
    upstream tomcat {
        server 127.0.0.1:8080;
    }

    server {
        listen 80;
        server_name im.test.com;
        location / {
                proxy_set_header        Host $host;
                proxy_set_header        X-Real-IP $remote_addr;
                proxy_pass http://tomcat;
        }
    }

server_name 是你的域名,这个域名就用来被访问Tomcat,我们可以看到,Nginx监听的端口号为80端口,但是转发给了Tomcat端口。如果tomcat端口不为8080 需要修改upstream里对应的端口号

Tomcat

修改
     <Host name="im.test.com"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" />

      </Host>

name 为域名,和nginx对应。

发点nginx 和 tomcat 以及Linux下的干货

nginx -s reload  :修改配置后重新加载生效
nginx -s stop  :快速停止nginx
nginx -c /path/to/nginx.conf:启动nginx
nginx -t : 查看nginx文件配置路径
ps aux | grep nginx : 查看nginx路径

netstat -apn | grep 4040  查询端口号所占用的程序
kill -9 26105   杀死进程

tail -f catalina.out 实时查看tomcate日志信息
./shutdown.sh  关闭tomcat
./startup.sh 开启tomcat


rm -rf /var/log/httpd/access   将会删除/var/log/httpd/access目录以及其下所有文件、文件夹

rm -f /var/log/httpd/access.log   将会强制删除/var/log/httpd/access.log这个文件

unzip all.zip 解压缩

ssh haibor@1.2.3.4 Mac 连接linux

相关文章

网友评论

      本文标题:Nginx + Tomcat 配置

      本文链接:https://www.haomeiwen.com/subject/srrugttx.html