配置文件示例
server{ listen 80; server_name www.xxx.com; location ~* \.(jpg|png|jepg|js|css|xml|bmp|swf|gif|html)$ { root /data/wwwroot/aminglinux/; access_log off; expire 7d; } location / { proxy_pass http://127.0.0.1:8080/; proxy_set_header host $host; proxy_set_header x-real-ip $remote_addr; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; }}
说明:
首先,把各种静态文件的请求分离出来,单独由nginx处理。
其他请求直接代理8080端口,即tomcat服务。
以上就是nginx下怎么配置tomcat的详细内容。