search

Home  >  Q&A  >  body text

java-ee - Resource file processing problem when nginx reverse proxy tomcat

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?

迷茫迷茫2795 days ago641

reply all(2)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-16 17:25:08

    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

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-16 17:25:08

    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.

    reply
    0
  • Cancelreply