![通过 Nginx 运行 Mumble Django - 配置文件在重写中无限循环](https://linux22.com/image/593755/%E9%80%9A%E8%BF%87%20Nginx%20%E8%BF%90%E8%A1%8C%20Mumble%20Django%20-%20%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E5%9C%A8%E9%87%8D%E5%86%99%E4%B8%AD%E6%97%A0%E9%99%90%E5%BE%AA%E7%8E%AF.png)
我在配置 Nginx 代替 Apache 时遇到了一些问题,以便它能够为客户端提供 Mumble Django。我有 vhostsApache 和 Lighttpd 的配置- 让我把它们并排放在这里,为您节省点击次数 :)。Apache2 利用 WSGI 将 Django Python 作为 CGI 运行。据我所知,Lighttpd 的工作方式类似于 Nginx/PHP-FPM。
专用 Apache2 虚拟主机 - 配置:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
Alias /static/admin/ /usr/share/pyshared/django/contrib/admin/static/admin/
Alias /static/ /srv/mumble-django/htdocs/
Alias /mumble/media/ /srv/mumble-django/pyweb/mumble/media/
WSGIScriptAlias / /srv/mumble-django/mumble-django.wsgi
WSGIDaemonProcess mumble-django threads=25
WSGIProcessGroup mumble-django
WSGIScriptReloading Off
# Cache optimization - not necessarily needed for MD, but nice to have :)
FileETag None
<IfModule mod_headers.c>
Header unset ETag
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=86400, must-revalidate"
</FilesMatch>
<IfModule mod_deflate.c>
# compress content
AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript image/png image/jpeg image/gif
# properly handle requests coming from behind proxies
Header append Vary User-Agent
</IfModule>
</IfModule>
</VirtualHost>
Lighttpd 配置:
server.document-root = "/usr/local/www/mumble-django"
alias.url = (
"/static" => "/usr/local/www/mumble-django/htdocs/",
"/media" => "/usr/local/lib/python2.6/site-packages/django/contrib/admin/media/"
)
url.rewrite-once = (
"^(/media.*)$" => "$1",
"^(/static.*)$" => "$1",
"^(/.*)$" => "/mumble-django.fcgi$1",
)
fastcgi.server = (
"/mumble-django.fcgi" => (
"" => (
"socket" => "/tmp/mumble-django.sock",
"check-local" => "disable"
)
)
)
我转换的可耻的 Nginx 配置文件是这样的:
server {
listen 80;
server_name mumble-web-ui.imanov.name;
server_name_in_redirect on; # SEO: Avoid different host-names!
server_tokens off;
root /home/shehi/www-data/subdomains/mumble_web_ui;
merge_slashes on;
msie_padding on;
client_max_body_size 64M;
index index.php;
error_log /home/shehi/logs/error_log debug;
location /static
{
alias /home/shehi/www-data/subdomains/mumble_web_ui/htdocs/;
internal;
}
location /media
{
alias /home/shehi/www-data/subdomains/mumble_web_ui/pyweb/mumble/media/;
internal;
}
location /
{
# rewrite ^(/.*)$ /mumble-django.fcgi$1 last;
# try_files $uri $uri/ /mumble-django.fcgi$uri;
gzip on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
}
显然,我的配置陷入了无限循环:
http://mumble-web-ui.imanov.name/mumble/mumble/.. .../mumble/mumble/
所以,简而言之,我在这里做错了什么?提前感谢大家的帮助!