search
Homephp教程PHP开发Nginx server combines Nginx and tomcat to access jsp

Overview of this article:
JSP is a dynamic web technology standard. The method used is to insert program segments and JSP tags into HTML files to form JSP files. Using JSP to develop WEB applications can be developed across platforms. But jsp requires a javaEE server, and jsp files cannot be run under Nginx. This article will introduce how to access jsp file resources through Nginx and tomcat.

Configuration steps:

1. Environment installation

 JDK, tomcat and Nginx

 For the installation of JDK and tomcat, please refer to: http://www.cnblogs.com/jalja/p/6117048.html

 Nginx Installation: http://www.cnblogs.com/jalja/p/6104325.html

2. Combination of Nginx and tomcat

Our Nginx server port: 80; tomcat port number: 8080

In the Nginx configuration file directory Create a jsp.conf file under (/usr/local/nginx/conf) with the following content:

user  nobody;
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    server {
        #============监听的Nginx端口========
        listen 121.42.41.143:80;
        server_name  121.42.41.143;
        access_log  logs/host.access.log  combined;
        #============对不同请求的处理=============
        location ~ \.(jsp|jspx|do|action)?$ 
        {   
            #=============tomcat的资源位置============
            root /usr/local/tomcat1.7/webapps/jsp;
            index index.jsp index.jspx index.do;
            #==========Nginx提供的代理============
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Server $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            #=== 如果遇到.jsp .jspx .do .action 的请求就进入该服务器(tomcat)===
            proxy_pass http://121.42.41.143:8080;
        }
    }

}

3. Close the nginx server, restart and load the jsp.conf configuration file


Close the Nginx server: [root@iZ28b4kreuaZ conf]# killall -9 nginx

 Start the Nginx server and load the jsp.conf configuration file: [root@iZ28b4kreuaZ conf]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/jsp. conf

4. Whether the test is successful:

Access the Nginx server http://121.42.41.143/jsp/index.jsp

Nginx server combines Nginx and tomcat to access jsp

The principle of accessing Jsp under Nginx: when the user accesses .jsp .jspx .do .action When requesting resources, Nginx hands such requests to its proxy server (tomcat server) for processing.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.