V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
571726193
V2EX  ›  Java

项目结构 Springboot + Html 没有分离 在一个项目里

  •  
  •   571726193 · 2019-06-06 10:08:25 +08:00 · 2996 次点击
    这是一个创建于 1776 天前的主题,其中的信息可能已经有所发展或是发生改变。

    页面正常进,访问接口 404

    通过 nginx 代 8066 端口访问 404

       Request URL: http://localhost:8066/black/list?search=&page=1&limit=10
       Request Method: GET
       Status Code: 404 
       Remote Address: 127.0.0.1:8066
       Referrer Policy: no-referrer-when-downgrade
    

    通过 tomcat 访问 200

       Request URL: http://localhost:81/black/list?search=&page=1&limit=10
       Request Method: GET
       Status Code: 200 
       Remote Address: [::1]:81
       Referrer Policy: no-referrer-when-downgrade
    

    nginx.config

    upstream serverlist {
        server 127.0.0.1:81 weight=1;
        server 127.0.0.1:83 weight=2;
    	server 127.0.0.1:85 weight=3;
    
    }
    
    #gzip  on;
    
    server {
        listen       8066;
        server_name  127.0.0.1;
    
        #charset koi8-r;
    
        #access_log  logs/host.access.log  main;
    
        location / {
            #root   \blacklist;
            #index  \black-list.html;
    		proxy_pass http://serverlist;
    		proxy_redirect default;
            proxy_connect_timeout 1s;
            proxy_read_timeout 5s;
            proxy_send_timeout 2s;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            add_header 'Access-Control-Allow-Headers' 'Content-Type';
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Methods' 'GET';
    
        }
    
    	
    	location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|woff)$ {
             proxy_pass http://serverlist;
    		 
        }
    
    8 条回复    2019-06-06 14:24:47 +08:00
    leeyuzhe
        1
    leeyuzhe  
       2019-06-06 10:38:02 +08:00 via Android
    看下 Nginx 日志
    LeeSeoung
        2
    LeeSeoung  
       2019-06-06 10:43:20 +08:00
    nginx 只留 location proxy_pass,upstream 里只留 81 端口 一步一步加条件看加了哪个挂了。。
    571726193
        3
    571726193  
    OP
       2019-06-06 13:32:16 +08:00
    @leeyuzhe log 里就这个 2019/06/06 09:31:54 [notice] 19756#4324: signal process started
    571726193
        4
    571726193  
    OP
       2019-06-06 13:34:21 +08:00
    @LeeSeoung 并没有用 只留一个 proxy_pass 还是 一样的
    imycc
        5
    imycc  
       2019-06-06 13:41:09 +08:00 via iPhone
    nginx 的 access log 看一下 upstream 分配到哪
    404 的时候应用有没有收到请求
    排查下。再不行就用 tcpflow 监听下这几个端口进来的请求是啥合适的。
    kevinWHX
        6
    kevinWHX  
       2019-06-06 13:42:06 +08:00
    看一下 access.log
    571726193
        7
    571726193  
    OP
       2019-06-06 14:15:03 +08:00
    @imycc 127.0.0.1 - - [06/Jun/2019:13:33:49 +0800] "GET /black/list?search=&page=1&limit=10 HTTP/1.1" 404 163 "http://localhost:8066/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"


    这个是咋回事
    571726193
        8
    571726193  
    OP
       2019-06-06 14:24:47 +08:00
    @kevinWHX "GET /black/list?search=&page=1&limit=10 HTTP/1.1" 404 163 "http://localhost:8066/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"



    没看出来哪里不对啊
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3517 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 11:40 · PVG 19:40 · LAX 04:40 · JFK 07:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.