You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

已解决:Django+uWSGI+Nginx+Let’s Encrypt无法访问HTTPS问题

Fixing HTTPS Access Failures with Django/uWSGI/Nginx + Let's Encrypt

I recently ran into a frustrating issue where I couldn't get HTTPS access working for my Django app hosted on uWSGI and Nginx, even after setting up Let's Encrypt certificates. Let me walk through what went wrong and how I fixed it.

The Problem

After configuring Let's Encrypt and setting up my custom Nginx config (project_rest.conf) linked to /etc/nginx/sites-enabled/, HTTPS connections just wouldn't work. Oddly enough, when I started uWSGI with uwsgi --ini uwsgi.ini (using my virtualenv setup), I could access the site just fine at mysitedomain.com:8000—so the app itself was running, but the HTTPS routing was broken.

What I Found

Digging into Nginx's configs, I realized the default enabled site file (/etc/nginx/sites-enabled/default) was still active. This file already had its own inbound traffic rules, and it was conflicting with my custom HTTPS setup. Nginx was prioritizing this default config over my project's rules, which meant my Let's Encrypt HTTPS settings weren't being applied at all.

The Fix

The solution was straightforward: delete the conflicting default enabled site file:

sudo rm /etc/nginx/sites-enabled/default

Then reload Nginx to make sure the changes take effect:

sudo systemctl reload nginx

Key Config Context

For reference, here's the setup I was working with:

  • project_rest.conf: My custom Nginx config for the Django project, which I had already linked to /etc/nginx/sites-enabled/ (this includes all the HTTPS rules pointing to my Let's Encrypt certs).
  • /etc/nginx/sites-available/default: The original default config file—you can keep this as a backup if you want, just don't leave it linked to sites-enabled.
  • uwsgi.ini: My uWSGI config set up for the app's virtualenv, which worked perfectly when I launched it directly (hence the port 8000 access working).

Once I removed that default enabled site, my HTTPS config kicked in, and the site was accessible via https://mysitedomain.com without any issues.

内容的提问来源于stack exchange,提问作者Hide

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:38:38