我正在尝试配置nginx以便为远程VPS上的django项目提供静态内容.我为我的nginx实例使用以下配置:server {server_name myVPSip;access_log off;location /static/ {alias /usr/local/pcat/static/;}location / {proxy...

我正在尝试配置nginx以便为远程VPS上的django项目提供静态内容.我为我的nginx实例使用以下配置:
server {
server_name myVPSip;
access_log off;
location /static/ {
alias /usr/local/pcat/static/;
}
location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
}
我在../nginx/sites-available/中创建了配置文件,将其链接到/ sites-enabled /,然后重新启动了nginx,但是当我命中myip:8001 / static时,我得到了django 404.
解决方法:
您不应该在123.123.123.123:8001之前访问您的网站,因为那是django使用的端口.您应该访问运行nginx的123.123.123.123(即端口80).
沃梦达教程
本文标题为:python-使用Nginx提供静态内容的Django


基础教程推荐
猜你喜欢
- python学习-linux基本操作 2023-09-04
- python-增加熊猫数据帧创建时的内存使用率 2023-11-11
- Windows下Python环境搭建 2023-09-03
- ubuntu 下python环境的切换使用 2023-09-04
- C++通过内嵌解释器调用Python及间接调用Python三方库 2023-08-11
- Python原始套接字到以太网接口(Windows) 2023-11-11
- python进程池:multiprocessing.pool 2023-09-04
- 各种相似度计算的python实现 2023-09-04
- Python YAML文件的读写操作详解 2022-08-30
- Linux下Python2升级Python3 2023-09-03