Nginx+tomcat return 404 page for Action request

Source: Internet
Author: User

Today to customers to do the demand, the basic nginx+tomcat,tomcat before, 8081 ports, and now the customer has a domain name, I hope that the domain name can be accessed directly, then there are only two ways: Change the Tomcat port, 8081 to 80, or with a third-party web forwarding, For example, using Nginx, this time I will give customers the use of nginx, the result of customer access to a registration page Tmalluser!toregistpage.action error 404

I have a separate test page with Tomcat, can open, no problem, that must be nginx configuration forwarding problems.

server {listen-default; server_name domain name; index index.html index.htm index.jsp;root/www/default;location ~ \.jsp$ {proxy_pass Http://127.0.0.1:8 080;} Location ~. *\. (gif|jpg|jpeg|png|bmp|swf) ${expires 30d;} Location ~. *\. (JS|CSS)? ${expires 1h;} Access_log/www/log/nginx/access/default.log;}

I used the company script run, mainly for the sake of trouble, access to the homepage, login page is no problem, is to visit the registration page tmalluser!toregistpage.action error, ah, now know, easy is trouble!

Carefully read the other information, found that the configuration has a problem, according to the configuration, he simply forwarded the JSP page to Tomcat processing, but the registration page is not JSP, is an action request, so, did not transfer to Tomcat processing, the error 404.

#location  ~ \.jsp$ {#proxy_pass     http://127.0.0.1:8081;#}         location / {                index index.html index.htm index.jsp;                proxy_pass     http://127.0.0.1:8081;                proxy_set_header   Host               $host;                proxy_set_header   X-Real-IP         $remote _addr;                proxy_set_header    x-forwarded-for   $proxy _add_x_forwarded_for;        } 

Comment out the original, the new field means that the site directory is forwarded to the Tomcat processing, including static page HTML.

Previous attempts at static page separation, but do not know how to differentiate, let the action page to Tomcat processing, simply, the diagram is simple, all forwarded to the Tomcat processing. If, have to understand this configuration classmate, can mail me, mutual exchange, learn from each other, thank you!


This article is from the "Ops Space" blog, so be sure to keep this source http://drinkboy.blog.51cto.com/10606290/1770183

Nginx+tomcat return 404 page for Action request

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.