【发布时间】:2018-06-28 18:40:04
【问题描述】:
我正在尝试让 Flask-RESTplus 的 Swagger UI 在使用 Nginx 作为代理的服务器上运行。
Swagger 在 /api 上提供服务,并使用 http://localhost:5000/api 在本地工作。我正在尝试将 Nginx 设置为代理,以便我可以转到 http://ServerIP/api 并查看 Swagger UI。
我已经为 Nginx 尝试了很多配置,目前有
location /api {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:5000;
proxy_redirect off;
proxy_intercept_errors on;
proxy_http_version 1.1;
}
但是,当我转到http://ServerIP/api 时,我只看到一个空白页。在 Chrome 开发工具中有一个错误:
Uncaught ReferenceError: SwaggerUIBundle is not defined
at window.onload (api:75)
指的是:
<script src="/swaggerui/swagger-ui-bundle.js"></script>
<script src="/swaggerui/swagger-ui-standalone-preset.js"></script>
<script type="text/javascript">
window.onload = function() {
const ui = window.ui = new SwaggerUIBundle({
但我可以到达(200 OK,提供 javascript 文件) http://ServerIP/swaggerui/swagger-ui-bundle.jshttp://ServerIP/swaggerui/swagger-ui-standalone-preset.js。
任何想法可能是什么问题?
【问题讨论】:
标签: nginx flask swagger swagger-ui flask-restplus