配置nginx+tomcat
2016-07-29 00:00
411 查看
配置nginx并指定默认的jsp目录,官方给了一个jetty的例子
目标:域名http://app29551.qzoneapp.com 直接访问tomcat下的jiuchongju目录的项目
假设tomcat的服务端口为8080,nginx端口为80
1、主要是修改nginx的配置文件,这里我让nginx将请求转发给tomcat,并指定默认的请求文件
2、配置tomcat,指定默认的项目目录。其实就是修改tomcat的conf下的server.xml文件
3、配置项目的默认访问页,这里我想让请求当前项目的默认访问页面为index_tel.jsp
定义项目目录下的WEB-INF/web.xml文件
这样就会先寻找index_tel.jsp作为默认页,找不到后会访问 index.jsp
目标:域名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
相关文章推荐
- suse下定制开启启动tomcat的计划任务
- 将nginx和tomcat结合
- 成为Java GC专家(4):Apache的MaxClients参数及其对Tomcat执行Full GC的影响
- 成为Java GC专家(4):Apache的MaxClients参数及其对Tomcat执行Full GC的影响
- Tomcat+Apache2.2使用mod_proxy做请求转发
- jar冲突导致Tomcat运行错误 ...
- 写一个bat来快速打开并编辑tomcat配置文件
- 在gwt1.6 的host模式中 使用tomcat
- 写一个bat清理tomcat缓存
- Tomcat+Apache2.2使用mod_proxy做请求转发
- jar冲突导致Tomcat运行错误 ...
- 写一个bat来快速打开并编辑tomcat配置文件
- 在gwt1.6 的host模式中 使用tomcat
- 写一个bat清理tomcat缓存
- Tomcat 启动报java.lang.AbstractMethodError错
- linux下安装tomcat
- Intellij IDEA 远程debug、远程tomcat部署项目
- tomcat部署web应用,并使用域名(IP)直接访问
- Myeclipse修改项目名称,而发布到Tomcat上的项目名称却未修改。
- 为什么Servlet修改之后,Tomcat都得重启,servlet才会生效!