Tag: Nginx

强制nginx发送特定的Content-Type

如何覆盖nginx默认的内容types? 目前当我请求01.dae文件的时候, Content-Type: application/octet-stream; 我想要它 Content-Type: application/xml; 我试过类似的东西 location ~* \.dae$ { types { }; default_type application/xml; } 和 location ~* \.dae$ { add_header Content-Type application/xml; } 但没有任何工作。

如何configurationnginx以启用“文件浏览器”模式?

一旦我看到这个之前,当我键入一个URL http://test.com/test/ ,而不是给我一个HTML页面,它给了我一个“文件浏览器”像接口浏览给定位置的所有文件。 我认为这可能是一个nginx模块,可以在位置上下文中启用。 nginx.conf文件: worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name 122.97.248.252; location /test { root /home/yozloy/html/; autoindex on; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } 更新error.log 2012/05/19 20:48:33 [error] […]

nginx的add_header不工作

我有一个有趣的问题,每当我在虚拟主机configuration中使用add_header运行nginx的PHP和PHP- add_header的Ubuntu服务器,它根本不工作,我不知道我在做什么错了。 这是我的configuration文件: server { listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6 root /var/www/example.com/webroot/; index index.html index.htm index.php; # Make site accessible from http://www.example.com/ server_name www.example.com; # max request size client_max_body_size 20m; # enable gzip compression gzip on; gzip_static on; gzip_min_length 1000; […]

UnicodeEncodeError:'ascii'编解码器不能编码字符

当上传非ASCII字符的文件时,我得到UnicodeEncodeError: Exception Type: UnicodeEncodeError at /admin/studio/newsitem/add/ Exception Value: 'ascii' codec can't encode character u'\xf8' in position 78: ordinal not in range(128) 查看完整的堆栈跟踪 。 我用MySQL和nginx和FastCGI运行Django 1.2。 这是一个根据Django Trac数据库修复的问题,但是我仍然有问题。 任何build议如何解决是受欢迎的。 编辑:这是我的形象领域: image = models.ImageField(_('image'), upload_to='uploads/images', max_length=100)

nginx ./configure错误Ubuntu的12.04

下载后,尝试configurationnginx时,执行命令./configure他得到这个错误 ./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using –without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using –with-pcre=<path> option. 我执行 apt-get build-dep nginx 命令um得到以下错误 The following packages have unmet dependencies: […]

Nginx将非www前缀域重写为www前缀域

我看到Nginx的HttpRewriteModule文档有一个例子,把一个www前缀的域重写为一个非www前缀的域: if ($host ~* www\.(.*)) { set $host_without_www $1; rewrite ^(.*)$ http://$host_without_www$1 permanent; # $1 contains '/foo', not 'www.mydomain.com/foo' } 我怎样才能做到相反 – 将一个非www前缀域重写到一个www前缀域? 我想也许我可以做下面的事情,但Nginx不喜欢嵌套的if语句。 if ($host !~* ^www\.) { # check if host doesn't start with www. if ($host ~* ([a-z0-9]+\.[a-z0-9]+)) { # check host is of the form xxx.xxx (ie no subdomain) set $host_with_www […]

添加nginx.exe作为Windows系统服务(如Apache)?

我将NGINX设置为静态内容的前端服务器,并使用Apache作为其他事物的后端服务器。 事情是我无法find一个合乎逻辑的答案,让我做nginx.exe一个Windows系统服务(如我的Apache)。 任何遇到这个答案?

运行django时,扭曲的服务器意外崩溃

我正在使用本网站上的django-on-twisted脚本来运行一个django应用程序。 所有请求都由一个nginx服务器提供服务,该服务器将相关请求反向代理为扭曲。 我有一个API的API设置,基本上只是接收请求,并在发送响应之前对get参数进行一些处理。 但是,当一个特定的客户端正在打api时,扭曲的服务器就会closures。 下面粘贴的是Nginx的日志: the.ip.of.client – – [21/Apr/2012:11:30:36 -0400] "GET /api/url/?get=params&more=params HTTP/1.1" 499 0 "-" "Java/1.6.0_24" 扭曲的日志显示什么,但在这一点上扭曲停止工作。 通过错误代码499,我假设客户端意外closures连接,这是我没有问题。 客户是否收到回复对我来说并不重要。 这里是相关的Django视图: def api_url(request): if request.GET: get_param = request.GET.get('get', [''])[0] more_param = request.GET.get('more', [''])[0] #some processing here based on the get params return HttpResponse('OK') else: raise Http404 来自客户的请求是有效的请求,不会以不利的方式影响处理。 我已经从shell中testing了它。 当我在django开发服务器上尝试时,它也以同样的方式崩溃,没有留下任何接收请求的痕迹。 从浏览器进行testing时,一切正常。 此外,扭曲的服务器适用于所有常规使用情况。 这是我第一次面临一个问题。 任何帮助或指针将不胜感激。

使用Nginx运行PHP时未find文件

最近我安装了最新版本的Nginx,看起来我很难用PHP来运行它。 这是我用于域的configuration文件: server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.php; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; } } 这里是错误日志文件中的错误: FastCGI sent in stderr: "Primary script unknown" while reading response […]

如何在OS X上重新启动nginx

我在OS X 10.8上使用nginx 。 刚安装kill nginx_pid nginx却找不到重启nginx的方法,除了kill nginx_pid说kill 64116 。 想知道是否有更好的方法来重新启动nginx 。 在Google和SO上find了一些方法,但没有奏效: nginx -s restart sudo fuser -k 80/tcp ; sudo /etc/init.d/nginx restart nginx -s restart的错误信息是 nginx: [error] open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory) 有时也会得到这个错误消息: nginx: invalid option: "-s restart"