/swagger-ui/index.html找不到

时间:2018-07-14 09:05:16

标签: nginx jhipster

我按照这里在centos 7(使用docker)中设置分离的前端和后端,使用nginx托管我的前端,我的网站可以正常工作,并且所有/ api / ....请求都可以正常工作,当我想检查swagger提供的RESTful API时,出现404错误,fiddler说:

not found /swagger-ui/index.html

我在主机上打开8080并浏览了swagger-ui文件夹,index.html就在那。并且所有www文件夹都被授予755权限。

nginx site.conf如下:

server {
    listen 80;
    index index.html;
    server_name localhost;
    error_log  /var/log/nginx/error.log;

    location / {
        root /usr/share/nginx/html;
    }
    location /api {
        proxy_pass http://www.example.com:8080/api;
    }
    location /management {
        proxy_pass http://www.example.com:8080/management;
    }
    location /v2 {
       proxy_pass http://www.example.com:8080/v2;
    }
    location /swagger-ui {
        proxy_pass http://www.example.com:8080/swagger-ui;
    }
    location /swagger-resources {
        proxy_pass http://www.example.com:8080/swagger-resources;
    }
}

怎么了?

===============================已更新 发出后:

sudo docker logs -f -t --tail 100 docker_nginx_1

在日志文件中发现错误:

2018-07-14T17:35:40.904857522Z 187.67.50.246 - - [14/Jul/2018:17:35:40 +0000] "GET /cgi/common.cgi HTTP/1.1" 404 169 "-" "Wget(linux)" "-"
2018-07-14T17:35:40.904920067Z 2018/07/14 17:35:40 [error] 5#5: *23 open() "/usr/share/nginx/html/cgi/common.cgi" failed (2: No such file or directory), client:187.67.50.246, server: localhost, request: "GET /cgi/common.cgi HTTP/1.1", host: "39.107.246.223"
2018-07-14T17:35:43.896984659Z 187.67.50.246 - - [14/Jul/2018:17:35:43 +0000] "GET /stssys.htm HTTP/1.1" 404 169 "-" "Wget(linux)" "-"

1 个答案:

答案 0 :(得分:0)

在我注释掉之后它会起作用:

location /swagger-ui {
    proxy_pass http://www.example.com:8080/swagger-ui;
}

我认为swagger-ui由nginx提供,而不是由后端提供。