Apache agent Tomcat could not load css,js, pictures and other resources to solve the method

Source: Internet
Author: User

This problem for a long time, should be the development of code to get the relative path of the project and the absolute path of the problem, but do not change the code with the Apache proxy solution can be implemented? The answer is Yes.


Below is the configuration of Apache proxy tomcat access and HTTPS access

Apache2.2,yum installation of

tomcat7,jdk1.7


Tomcat's server.conf Configuration

Add context to Host

unpackwars= "true" autodeploy= "true" >

<context docbase= "/usr/local/tomcat/apache-tomcat-7.0.70/webapps/test/"

Path= "" reloadable= "true" crosscontext= "true"/>

Save


HTTPD.CONF configuration file, Implementation of HTTP Automatic skip to https, certificate and so on is not introduced.

<virtualhost *:80>

ServerName localhost

Proxyvia OFF

Proxyrequests OFF

<ifmodule mod_rewrite.c>

Rewriteengine on

rewritecond%{server_port} 80

Rewriterule ^.*$ https://%{server_name}%{request_uri} [r=301,l]

</IfModule>

</VirtualHost>


ssl.conf configuration file main section, URL jump to tomcat service, 9090/after No addition to the project, Because the docbase in the server.conf file already has test set, the default access to Tomcat's 9090 port is to access test, so Apache jumps directly to the root/on the LINE.

Proxyrequests OFF

<proxy *>

Options MultiViews

Order Deny,allow

Allow from all

</Proxy>

proxypass/http://172.26.124.219:9090/

proxypassreverse/http://172.26.124.219:9090/

</VirtualHost>


This is the browser input/http/domain name

directly on it. Have accumulated experience, hope to help .....



This article is from the "11617433" blog, please be sure to keep this source http://11627433.blog.51cto.com/11617433/1942040

Apache agent Tomcat could not load css,js, pictures and other resources to solve the method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.