nginx访问无法访问动态java项目,访问jsp页面,浏览器弹出下载jsp问题解决

nginx访问无法访问动态java项目,访问jsp页面,浏览器弹出下载jsp问题解决

 

这是由于nginx.conf文件配置缺少对jsp等动态文件处理的配置

server {
    listen 80;
    server_name _;
    access_log /data/wwwlogs/access_nginx.log combined;
    root /data/wwwroot/default;
    index index.html index.htm index.php;
    #error_page 404 /404.html;
    #error_page 502 /502.html;
    location /nginx_status {
      stub_status on;
      access_log off;
      allow 127.0.0.1;
      deny all;
    }
    location / {
      try_files $uri @apache;
    }
    location @apache {
      proxy_pass http://127.0.0.1:88;
      include proxy.conf;
    }

    location ~ [^/]\.php(/|$) {
      proxy_pass http://127.0.0.1:88;
      include proxy.conf;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
      expires 30d;
      access_log off;
    }
    location ~ .*\.(js|css)?$ {
      expires 7d;
      access_log off;
    }
    location ~ ^/(\.user.ini|\.ht|\.git|\.svn|\.project|LICENSE|README.md) {
      deny all;
    }
  }
########################## vhost #############################
  include vhost/*.conf;
}

我们需要在nginx.congf配置中缺少这段,这段是对java项目的转发配置

	location ~ .(jsp|jspx|do)?$ {

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_pass http://127.0.0.1:8080;

}

补充完整后,nginx就可以正常转发jsp。

你可能感兴趣的:(nginx访问无法访问动态java项目,访问jsp页面,浏览器弹出下载jsp问题解决)