仅nginx重定向上的Whitelabel错误页面

时间:2019-10-21 00:42:21

标签: spring-boot tomcat

不知道为什么通过Nginx重定向无法处理请求。

我能够直接从tomcat服务器获取响应,但无法通过nginx重定向获得响应?

有什么主意吗?

无法通过Nginx定向获得

  

http://tw-realestate.com/api/v1/transactions?minPing=15&maxPing=30&minYear=2015&maxYear=2019&minAge=0&maxAge=50&minBuildingFloor=1&maxBuildingFloor=30&property_type=any&building_type=%E5%85%AC%E5%AF%93(5%E6%A8%93%E5%90%AB%E4%BB%A5%E4%B8%8B%E7%84%A1%E9%9B%BB%E6%A2%AF)&floor=-1&north=25.068828022605665&east=121.47698632976562&south=25.047904830135664&west=121.44093744060547

通过直接访问tomcat来确定响应

  

http://localhost:8080/xproj/api/v1/transactions?minPing=15&maxPing=30&minYear=2019&maxYear=2019&minAge=0&maxAge=50&minBuildingFloor=1&maxBuildingFloor=30&property_type=any&building_type=公寓(5樓含以下無電梯)&floor=-1&north=25.07377234743186&east=121.4726947953418&south=25.04295946150219&west=121.4452289750293

nginx

upstream tomcat {
    server tomcat:8080;
}

server {
    listen 80;

    root  /etc/nginx/public_html;

    location / {
        auth_basic           "Development mode";
        auth_basic_user_file /etc/nginx/conf.d/htpasswd;
        ...
        gzip_disable "MSIE [1-6]\.";
    }

    location /api/v1 {
        auth_basic           "Development mode";
        auth_basic_user_file /etc/nginx/conf.d/htpasswd;        
        proxy_pass         http://tomcat/xproj/api/v1/;
        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;
        proxy_set_header   X-Forwarded-Host $server_name;
    }

Sping过滤器

        @Override
        protected void configure(HttpSecurity http) throws Exception {

            http.csrf().disable();


            http.authorizeRequests()
                    .antMatchers(HttpMethod.POST, SecurityConstants.SIGN_UP_URL)
                    .permitAll();

            http.authorizeRequests()
                    .antMatchers("/guests").permitAll()
                    .antMatchers("/guests/**").permitAll();

            http.authorizeRequests()
                    .antMatchers("/secured/**").authenticated()
                    .anyRequest().permitAll()
                    .and()
                    .formLogin().permitAll()
                    .and()
                    .addFilter(getAuthenticationFilter())
                    .addFilter(new AuthorizationFilter(authenticationManager()))
                    .sessionManagement()
                    .sessionCreationPolicy(SessionCreationPolicy.STATELESS);
        }


        protected AuthenticationFilter getAuthenticationFilter() throws Exception {
            final AuthenticationFilter filter = new AuthenticationFilter(authenticationManager());
            filter.setFilterProcessesUrl("/users/login");
            return filter;
        }

弹簧控制器

    @CrossOrigin(origins = "*")
        @GetMapping(path = "/transactions")
        public ResponseEntity<TransactionResponse> getTransactions(
                @ModelAttribute QueryFilter filter
        ) {
            ....
        }         

Tomcat错误消息

    -5.1.10.RELEASE.jar:5.1.10.RELEASE]
    tomcat        |     at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
    tomcat        |     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:893) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
    tomcat        |     at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:798) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
    tomcat        |     at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
    tomcat        |     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
    tomcat        |     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
    tomcat        |     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
    tomcat        |     at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
    tomcat        |     at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) ~[servlet-api.jar:na]
    tomcat        |     at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.1.10.RELEASE.jar:5.1.10.RELEASE]
    tomcat        |     at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[servlet-api.jar:na]
    tomcat        |     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [catalina.jar:8.5.35]
    tomcat        |     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.35]
    tomcat        |     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-websocket.jar:8.5.35]
    tomcat        |     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.35]
    tomcat        |     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.35]
    tomcat        |     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:320) ~[spring-security-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    tomcat        |     at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:127) ~[spring-security-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    tomcat        |     at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:91) ~[spring-security-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    tomcat        |     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    tomcat        |     at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:119) ~[spring-security-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    tomcat        |     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    tomcat        |     at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:137) ~[spring-security-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    tomcat        |     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    tomcat        |     at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:111) ~[spring-security-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    tomcat        |     at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:334) ~[spring-security-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]
    tomcat        |     at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:170) ~[spring-security-web-5.1.6.RELEASE.jar:5.1.6.RELEASE]

0 个答案:

没有答案