Tomcat items are downloaded using pictures and files from Nginx

Source: Internet
Author: User
Tags java web

Busy for several days, and finally small achievements, sharing, also for example, I generally around the wall, badly beaten beginners reference.

First of all, I want to achieve, if you do not want the current I am powerless.

The purpose is simple. Pictures and file downloads from previous projects are placed in the project and are now on the file server.

The project is both a Java Web JSP project and a file server with Nginx in the Liunx (CENTOS6) system.

The picture that is displayed is the picture that is accessed in the Nginx and the file is downloaded.

Prerequisite: Java Web project run no problem, Nginx has been built.

Modify the nginx.conf file,

192.168.1.113 is a virtual machine that installs both the IP of the Nginx system. The picture is placed under the directory NGINX/MOU/PHT, and so is the file.

You can access Tomcat on this computer after the browser in the Windows system enters 193.168.1.113/carriage return. You can access the published items later with the project name. Ashamed of my style has dropped ... You can access the project as you do with native IP. It's two ways of visiting.

The first location is to intercept a picture request on a virtual machine, and the second is to file a download. Add that line is to prevent the browser directly to display TXT, that is, directly download the meaning of the file.

First, make sure that the browsers on the virtual Machine and window System have no problems accessing the pictures in the Nginx. Download is also the same OH.

In a Web project, the picture src to display is changed to the IP of the virtual machine and the interception rules that you set yourself. Files are the same.

Share My directory structure:


Look at the effect:


Finally spit the sentence, the cache is too powerful ... Remember to clear out the cache.

And also. If the browser in the virtual machine can access resources on the Nginx, but not on this machine (window), and both can ping the same, use service iptables stop on the Liux system and try again after shutting down the firewall.

If the picture is not accessible, please click http://forgetlove.iteye.com/blog/2004352

Related Article

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.