java-ee - Resource file processing problem when nginx reverse proxy tomcat
迷茫
迷茫 2017-05-16 17:23:08
0
2
640

The configuration on nginx is as follows


48 location ^~ /bgmonitor/ { 50 proxy_pass http://localhost:8080/; 51 }

Requests in the form of www.mr.org/bgmonitor are forwarded to the local tomcat on port 8080

tomcat configuration is as follows

 <Context docBase="/Users/mr/Documents/code_pool/bgmonitor-git/bgmonitor-web/target/bgmonitor" path="" reloadable="true"/>

Page rendering uses velocity, the resource file reference path is:

   <!-- bootstrap 3.0.2 -->
    <link href="${rc.contextPath}/css/bootstrap.css" rel="stylesheet" type="text/css"/>
    <!-- font Awesome -->
    <link href="${rc.contextPath}/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
    <!-- Ionicons -->
    <link href="${rc.contextPath}/css/ionicons.min.css" rel="stylesheet" type="text/css"/>
    <!-- Theme style -->
    <link href="${rc.contextPath}/css/AdminLTE.css" rel="stylesheet" type="text/css"/>

Phenomenon

When accessing, because ${rc.contextPath} is empty, the entire resource path becomes /css/AdminLTE.css. This request cannot be forwarded normally after being sent to nginx

ask

How can I make the entire application work properly with minimal modifications?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
我想大声告诉你

Static files do not need to be forwarded. Deploy static files on nginx locally, such as

location ~* ^/(?:images/|js/|css/) {
    root /home/app/htdocs;
}

Specific how to configure the reference document

巴扎黑

See the blog for details:
http://blog.iaceob.name/nginx-proxy/
and
http://blog.iaceob.name/tomcat-multi-domain-binding/

This is the solution I use. It’s just my personal use. I haven’t found anyone else who has used it this way.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template