Linux » NGINX

NGINX

Last modified by Administrator on 30-03-2012

To add nginx yum repository, create a file named /etc/yum.repos.d/nginx.repo and paste one of the configurations below:

CentOS:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

yum install nginx

chkconfig --add nginx

chkconfig --levels 235 nginx on
service nginx start

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 typical XWiki installation we have XWiki running on http://localhost:8080/xwiki. Most probably, we want access XWiki via http://mydomain.com on standard 80 port. Tuning Nginx will give us desired result:

  • create file /etc/nginx/conf.d/tomcat.conf
  • put 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 XWiki application. Please note, that these settings are basic, for more flexible solutions refer to Nginx documentation

Tags:
Created by Administrator on 29-09-2012

Spaces

 | Arduino | Blog | Dashboard | Java | Linux | Main | MulltiWii | NEAX2000 | Radio | VOIP


This wiki is licensed under a Creative Commons 2.0 license
XWiki Enterprise 3.5 - Documentation