Nginx server: Access jsp and nginxtomcat in combination with tomcat

Source: Internet
Author: User

Nginx server: Access jsp and nginxtomcat in combination with tomcat

This document uses centos

Overview:
JSP is a technical standard for dynamic web pages. You can insert a program segment and JSP tag into an HTML file to form a JSP file. WEB applications developed using JSP can be developed across platforms. However, jsp requires the javaEE server. jsp files cannot be run in Nginx. This article describes how to use Nginx and tomcat to access jsp file resources.

Configuration steps:

1. Environment Installation

JDK, tomcat, and Nginx

JDK and tomcat installation, see: http://www.cnblogs.com/jalja/p/6117048.html

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

2. Integrate Nginx with tomcat

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

Create a jsp. conf file in the Nginx configuration file directory (/usr/local/nginx/conf). The file content is as follows:

User nobody; worker_processes 1; events {worker_connections 1024 ;} http {server {#============= listening Nginx port ======= listen 121.42.41.143: 80; server_name 121.42.41.143; access_log logs/host. access. log combined ;#============== processing different requests =================== location ~ \. (Jsp | jspx | do | action )? $ {#============== Tomcat resource location ========== root/usr/local/tomcat1.7/ webapps/jsp; index. jsp index. jspx index. do ##========== proxy provided by 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; #== If yes. jsp. jspx. do. the action request enters the server (tomcat) === proxy_pass http: // 121.42.41.143: 8080 ;}}}

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


Disable 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. Check whether the test is successful:

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

How to access Jsp in Nginx: when a user accesses resources of. jsp. jspx. do. action, Nginx sends such requests to its proxy server (tomcat server) for processing.

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.