zoukankan      html  css  js  c++  java
  • Nginx proxying for Tomcat applications

    As Tomcat is not a true web server, it's worth to use it as backend. Nginx is one of the best solutions for the frontend web server.

    So, after a typical XWiki installation we have XWiki running on http://localhost:8080/xwiki. Most probably, we want to access XWiki viahttp://mydomain.com on standard 80 port. Tuning Nginx will give us the desired result:

    • create this file /etc/nginx/conf.d/tomcat.conf
    • put the following code inside:
      server {
          listen       80;
          server_name  mydomain.com;
      # Root to the XWiki application
          root  opt/tomcat/webapps/xwiki;

          location / {
      #All "root" requests will have /xwiki appended AND redirected to mydomain.com again
              rewrite ^ $scheme://$server_name/xwiki$request_uri? permanent;
          }

          location ^~ /xwiki {
      # If path starts with /xwiki - then redirect to backend: XWiki application in Tomcat
             proxy_pass http://localhost:8080/xwiki;

          }
      }
    • restart nginx

    Now all http://mydomain.com/* requests will lead to the XWiki application. Please note that these settings are basic. For more flexible solutions please refer to the Nginx documentation.

  • 相关阅读:
    POJ 3126 Prime Path
    POJ 2429 GCD & LCM Inverse
    POJ 2395 Out of Hay
    【Codeforces 105D】 Bag of mice
    【POJ 3071】 Football
    【POJ 2096】 Collecting Bugs
    【CQOI 2009】 余数之和
    【Codeforces 258E】 Devu and Flowers
    【SDOI 2010】 古代猪文
    【BZOJ 2982】 combination
  • 原文地址:https://www.cnblogs.com/zhangqingsh/p/2976118.html
Copyright © 2011-2022 走看看