我有nginx到服务器到浏览器。我希望nginx能够为来自浏览器的websocket请求服务。 Nginx使用代理配置在内部代理django(gunicorn uwsgi)。我无法在nginx中为websocket设置配置。从互联网上尝试了不同的配置,但没有成功。我在nginx配置文件中的默认文件:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /usr/share/gmc/dist;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404 /index.html index.js;
}
location ~ /redfish.* {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://localhost:8000;
}
}
答案 0 :(得分:0)
这些是您需要申请django项目的基本设置:
server {
listen 80;
server_name **Server Name or IP**;
#Website LOGO:
location = /favicon.ico { access_log off; log_not_found off;}
#Static Files like CSS, JS
location = /static/ {
root /home/hitshell/website/project/
}
#Media Files like Images, Videos etc.
location = /media/ {
root /home/hitshell/website/project/
}
#proxy
location = / {
include proxy_params;
proxy_pass http://unix:/home/hitshell/website/project/project.sock;
}
}
<强>参考:强>
第一个在教程中间有一些缺少的配置。