我正在尝试使用Nginx作为代理从Flask-RESTplus获取Swagger UI .
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.js http://ServerIP/swaggerui/swagger-ui-standalone-preset.js .
任何想法可能是什么问题?
1 回答
类似的问题:Server response gets cut off half way through
在发送大型上游文件时,Nginx需要具有写入临时文件夹的权限 . 通常你会在_129039中看到它
解决这个问题,你知道nginx:nginx(除非你手动更改了用户),例如
sudo chown -R nginx:nginx /var/lib/nginx
. 如果权限不是't at least 7xx you may have to change that but that shouldn'是一个问题 .或者您可以设置
proxy_buffering off;
,但如果您希望连接比平时(速度或大小)更长,则不建议这样做 .