Tomcat7 nginx配置

我的环境是ubuntu.

1.先安装nginx:

apt-get install nginx

安装完后,可以先启动一下,试试nginx有没有启动起来:

/etc/init.d/nginx start

启动后:输入http:xxxxhost 看到 welcome to nginx就行了。


配置nginx:

切换到:

/etc/nginx/conf.d/

然后touch一下,新建一个以“.conf”结尾的文件,这儿我假设为my.conf

touch my.conf

然后输入以下内容,我这儿是APP后台,让所有请求都通过nginx过来,简单配置了一下:

server {
    listen       80 default;
    server_name  you domain;
	index index.html index.htm index.jsp;
	root /yourtomcat/webapps/;

	location \ {
		proxy_pass    http://127.0.0.1:8080;
	}

	location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
	{
		expires 30d;
	}

	location ~ .*\.(js|css)?$
	{
		expires 1h;
	}
}

如果你没有域名,在server_name那儿直接写"_"

配置完后reload一下nginx

/etc/init.d/nginx reload

访问的时候:

http://www.youdomain.com

具体到你webapp某个项目:http://www.youdomain.com/xxproject




你可能感兴趣的:(Tomcat7 nginx配置)