【问题标题】:Django swagger ui not accessible on nginx在 nginx 上无法访问 Django swagger ui
【发布时间】:2020-07-20 08:28:04
【问题描述】:

我已经按照下面的 url 使用 nginx、gunicorn 和 postgres 设置了 Django。

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-centos-7

现在我正在尝试访问 swagger ui。

Nginx 已启动并运行,但显示默认页面。

当我运行同一个项目时, python manage.py runserver myip:8000 然后访问相同的 url,我可以看到带有休息端点的实际 swagger ui。 我不确定我在这里做错了什么。

这是我添加到 nginx 文件中的内容。

server {
        listen 80;
        server_name <myipaddress>;

        location = /favicon.ico { access_log off; log_not_found off; }
        location /static/ {
            root /home/threat-dashboard/backend;
        }

        location / {
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://unix:/tmp/backend.sock;
        }
    }

【问题讨论】:

    标签: django nginx swagger-ui


    【解决方案1】:

    sock 文件路径错误。我将它从 /tmp/backend.sock 更正为 /tmp/backend/backend.sock 并解决了问题。

    【讨论】:

      猜你喜欢
      • 2018-06-08
      • 1970-01-01
      • 2019-06-01
      • 1970-01-01
      • 2020-02-25
      • 2019-03-25
      • 2020-03-16
      • 2018-08-08
      • 2022-08-17
      相关资源
      最近更新 更多