Swagger Nginx flask-restplus
Swagger Nginx flask-restplus
我正在尝试从 Flask-RESTplus 获取 Swagger UI,在使用 Nginx 作为代理的服务器上工作。
Swagger 在 /api 上运行并在本地使用 http://localhost:5000/api . I'm trying to setup the Nginx as a proxy so I can go to 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。
任何想法可能是什么问题?
类似问题:Server response gets cut off half way through
Nginx 在发送大型上游文件时需要有写入临时文件夹的权限。通常你会在 /var/log/nginx/error.log
like
中看到它
2018/06/28 16:34:48 [crit] ... open() "<tmp folder>/x/y/00000000z" failed (13:
Permission denied) while reading upstream, <request info...>
要解决此问题,您需要更改 nginx:nginx(除非您已手动更改用户),例如 sudo chown -R nginx:nginx /var/lib/nginx
。如果权限不是至少 7xx,您可能需要更改它,但这应该不是问题。
您也可以设置 proxy_buffering off;
,但如果您希望连接比平时更长(速度或大小),则不建议这样做。
我正在尝试从 Flask-RESTplus 获取 Swagger UI,在使用 Nginx 作为代理的服务器上工作。
Swagger 在 /api 上运行并在本地使用 http://localhost:5000/api . I'm trying to setup the Nginx as a proxy so I can go to 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。
任何想法可能是什么问题?
类似问题:Server response gets cut off half way through
Nginx 在发送大型上游文件时需要有写入临时文件夹的权限。通常你会在 /var/log/nginx/error.log
like
2018/06/28 16:34:48 [crit] ... open() "<tmp folder>/x/y/00000000z" failed (13:
Permission denied) while reading upstream, <request info...>
要解决此问题,您需要更改 nginx:nginx(除非您已手动更改用户),例如 sudo chown -R nginx:nginx /var/lib/nginx
。如果权限不是至少 7xx,您可能需要更改它,但这应该不是问题。
您也可以设置 proxy_buffering off;
,但如果您希望连接比平时更长(速度或大小),则不建议这样做。