nginx和tomcat做整合,nginx代理访问tomcat页面,一级页面能访问,但是二级页面提示404错误。

#usernobody;userwwwwww;worker_processes8;error_log/usr/local/nginx/logs/error.logcrit... #user nobody;
user www www;
worker_processes 8;

error_log /usr/local/nginx/logs/error.log crit;
#error_log logs/error.log notice;
#error_log logs/error.log info;

pid /usr/local/nginx/nginx.pid;

worker_rlimit_nofile 65535;

events {
use epoll;
worker_connections 65535;
}

http {
include mime.types;
default_type application/octet-stream;
# include /usr/local/nginx/conf/proxy.conf;
charset utf-8;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 300m;
#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 60;
tcp_nodelay on;
client_body_buffer_size 512k;
proxy_connect_timeout 5;
proxy_read_timeout 60;
proxy_send_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;

upstream tomcat_server {
server 192.168.0.3:8080;

}

#gzip on;

server {
listen 80;
server_name 192.168.0.3;
index index.html index.htm index.jsp index.do default.do;
root /home/www;
if (-d $request_filename)
{
rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
}

#charset koi8-r;

#access_log logs/host.access.log main;

location ~ \.(jsp|jspx|do)?$ {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://tomcat_server;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
access_log off;

#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;
}。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
展开
 我来答
andygulin
推荐于2016-04-20 · TA获得超过1678个赞
知道小有建树答主
回答量:1362
采纳率:0%
帮助的人:1117万
展开全部
user nobody;
worker_processes 2;

error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

pid logs/nginx.pid;

events {
worker_connections 1024;
}

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 tomcat_server {
server 192.168.130.128:8080 weight=5;
server 192.168.130.129:8080 weight=5;
ip_hash;
}

server {
listen 80;
server_name localhost;

charset utf-8;

access_log logs/host.access.log main;

location / {
proxy_pass http://tomcat_server;
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_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}

error_page 404 /404.html;

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式