配置nginx+tomcat
来源:互联网 发布:编辑矢量图的软件 编辑:程序博客网 时间:2024/04/30 03:58
配置nginx并指定默认的jsp目录,官方给了一个jetty的例子
目标:域名http://app29551.qzoneapp.com 直接访问tomcat下的jiuchongju目录的项目
假设tomcat的服务端口为8080,nginx端口为80
1、主要是修改nginx的配置文件,这里我让nginx将请求转发给tomcat,并指定默认的请求文件
- #user nobody;
- #modify by kongqz from 1 to 4
- worker_processes 4;
- #error_log logs/error.log;
- #error_log logs/error.log notice;
- #error_log logs/error.log info;
- #pid logs/nginx.pid;
- events {
- #modify by kongqz
- use epoll;
- worker_connections 2048;
- }
- http {
- include mime.types;
- default_type application/octet-stream;
- #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- # '$status $body_bytes_sent "$http_referer" '
- # '"$http_user_agent" "$http_x_forwarded_for"';
- #access_log logs/access.log main;
- sendfile on;
- #tcp_nopush on;
- #keepalive_timeout 0;
- keepalive_timeout 65;
- #gzip on;
- # upstream jiuchongju {
- # server localhost:8080;
- # ip_hash;
- # }
- server {
- listen 80;
- server_name app29551.qzoneapp.com;
- #charset koi8-r;
- #access_log logs/host.access.log main;
- root /usr/local/services/tomcat6/webapps/jiuchongju/;
- location / {
- index index_tel.jsp index.jsp index.html index.htm ;
- proxy_redirect off;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- client_max_body_size 10m;
- client_body_buffer_size 128k;
- proxy_buffers 32 4k;
- proxy_connect_timeout 3;
- proxy_send_timeout 30;
- proxy_read_timeout 30;
- proxy_pass http://127.0.0.1:8080;
- }
- #error_page 404 /404.html;
- # redirect server error pages to the static page /50x.html
- #
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- # proxy the PHP scripts to Apache listening on 127.0.0.1:80
- #
- #location ~ \.php$ {
- # proxy_pass http://127.0.0.1;
- #}
- # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
- #
- #location ~ \.php$ {
- # root html;
- # fastcgi_pass 127.0.0.1:9000;
- # fastcgi_index index.php;
- # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
- # include fastcgi_params;
- #}
- # deny access to .htaccess files, if Apache's document root
- # concurs with nginx's one
- #
- #location ~ /\.ht {
- # deny all;
- #}
- }
2、配置tomcat,指定默认的项目目录。其实就是修改tomcat的conf下的server.xml文件
- <Host name="localhost" appBase="webapps"
- unpackWARs="true" autoDeploy="true"
- xmlValidation="false" xmlNamespaceAware="false">
- <Context docBase="jiuchongju" path="/" reloadable="true" />
- <!-- SingleSignOn valve, share authentication between web applications
- Documentation at: /docs/config/valve.html -->
- <!--
- <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
- -->
- <!-- Access log processes all example.
- Documentation at: /docs/config/valve.html -->
- <!--
- <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
- prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>
- -->
- </Host>
3、配置项目的默认访问页,这里我想让请求当前项目的默认访问页面为index_tel.jsp
定义项目目录下的WEB-INF/web.xml文件
- <welcome-file-list>
- <welcome-file>index_tel.jsp</welcome-file>
- <welcome-file>index.jsp</welcome-file>
- </welcome-file-list>
这样就会先寻找index_tel.jsp作为默认页,找不到后会访问 index.jsp
0 0
- Nginx+Tomcat配置Tomcat集群
- nginx+tomcat配置
- 配置nginx+tomcat
- nginx+tomcat 配置相关
- Nginx+tomcat 配置
- Nginx+tomcat配置集群
- Nginx+Tomcat配置
- Nginx+tomcat配置集群
- startssl tomcat nginx 配置
- Nginx+tomcat配置集群
- JDK tomcat nginx配置
- Nginx + Tomcat + Terracotta配置
- nginx+tomcat集群配置
- 配置nginx+tomcat
- Nginx+tomcat配置集群
- nginx+tomcat集群配置
- Nginx+tomcat配置集群
- tomcat +nginx 配置
- Android Matrix
- TFTP与FTP的区别及Linux下TFTP的安装
- Search Insert Position
- clips 6.30 ubuntu 14.04 linux embedding使用
- 【记录】Menu的学习
- 配置nginx+tomcat
- CSDN-markdown编辑器说明[存档]
- jQuery学习笔记(1)---简单的登录输入控制
- Nginx+Tomcat+Memcached集群
- 蓝桥杯---数独(模拟 || dfs)
- 学习ucos和ARM体系结构心得
- Linux的进程/线程通信方式总结
- nginx和tomcat做整合,nginx代理访问tomcat页面,一级页面能访问,但是二级页面提示404错误。
- BZOJ 1138 POI2009 Baj 最短回文路 BFS