Articles of nginx

具有不同根的nginx正则expression式位置不按预期工作

我有以下两条规则: location / { root /var/www/default; } location ~* /myapp(.*)$ { root /home/me/myapp/www; try_files $uri $uri/ /handle.php?url=$uri&$args; } 当我浏览到myapp/foo它的工作方式 – 错误logging为404: *3 open() "/var/www/default/handle.php" failed (2: No such file or directory) – so它处理的正则expression式匹配,但只是没有使用正确的文档根 – 这是为什么? 为了logging,我试图得到由第二个位置处理的/ myapp / *请求,其他所有事情都是第一个。

nginx拒绝目录和要下载的文件

大师。 我有一个问题,我不知道如何解决它。 我正在和一些项目上的Git和Compass / SASS合作。 现在我想保护这些目录。 当我只去的文件夹它的一切正常 – 我得到了我所期望的403禁止。 location ~ /\.git { deny all; } 但是,当我尝试使用从git的configuration文件的完整path开始下载它。 与指南针相同的场景。 文件夹中还有一个config.rb文件,它也开始下载它。 我怎样才能防止这种行为? 我怎么能否认下载特定的文件?

caching破坏和包含Nginx的文件

在Apache中,您可以使用以下命令来cachingcss和js文件,并使用Apache的Include mod将它们作为单个文件进行caching: <FilesMatch "\.combined\.js$"> Options +Includes AddOutputFilterByType INCLUDES application/javascript application/json SetOutputFilter INCLUDES </FilesMatch> <FilesMatch "\.combined\.css$"> Options +Includes AddOutputFilterByType INCLUDES text/css SetOutputFilter INCLUDES </FilesMatch> <IfModule mod_rewrite.c> RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L] </IfModule> 我知道这是可能的nginx,但我似乎无法得到正确的语法。 – 编辑 – 添加一些代码 我到目前为止唯一的一件事是: location ~* (.+)\.(?:\d+)\.(js|css)$ { ssi on; try_files $uri $1.$2; } 我正在寻找的是能够结合所有js和css文件到单个文件使用combined关键字与数字caching破坏: style.combined.100.css javascript.combined.100.js […]

位置中的另一个根/别名产生403

我不希望phpMyAdmin在我的网站的文件夹,但他们应该分别访问http://test.example.site和http://test.example.site/phpMyAdmin 。 但是这个configuration似乎不起作用: 403上http://test.example.site/phpMyAdmin 在http://test.example.site/phpMyAdmin/index.php上No input file specified configuration如下。 server { server_name test.example.site; error_log /var/log/nginx/test.error.log error; access_log /var/log/nginx/test.access.log; root /home/me/test/www-site; gzip on; gzip_types application/x-javascript application/javascript text/javascript text/css; client_max_body_size 50m; location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { expires 1M; } location / { index index.php index.html index.htm; } location /phpMyAdmin/ { # one of those is included, both don't […]

nginx varnish nginx php-fpm:php的_SERVER的实际ip

这是具体的问题。 一个Nginx服务器(称为N1)侦听:80,并通过proxy_pass转发清漆Varnish在127.0.0.1:6081侦听,并转发到8080上的Nginx(N2)。N2与php-fpm套接字进行通信。 N1 <> V <> N2 <>点 N1: location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_pass http://varnish/; proxy_redirect off; } 目前 $ _SERVER ['REMOTE_ADDR'] =='127.0.0.1' 期望 $ _SERVER ['REMOTE_ADDR'] =='真正的远程地址'

nginx符号链接权限被拒绝/ 403在Mac OSX上禁止

所以我有一个在Mac OSX上运行的nginx服务器,我正尝试从其他地方在我的nginx www目录中创build一个符号链接。 在浏览器中,我得到了精彩的403 Forbidden错误。 在过去的几个小时里,我也尝试过让自己的生活变得模糊。 似乎没有任何关于它的堆栈。 有一件事情关注我,我不确定符号链接是否由Mac上的ngninx直接支持。 尝试使用disable_symlink指令会导致: nginx: [emerg] unknown directive "disable_symlinks" in /usr/local/etc/nginx/nginx.conf:44` 有关我的设置的一些信息: nginx -v : nginx version: nginx/1.4.2 要创build符号链接,请执行以下操作: cd /Users/levi/www ln -s "/Users/levi/Desktop/…/client" "/Users/levi/www/client" 日志中的错误: [error] 11864#0: *7 open() "/Users/levi/www/client" failed (13: Permission denied), client: 127.0.0.1, server: _, request: "GET /client HTTP/1.1", host: "localhost" 任何帮助深表感谢。 如果有更多的信息可以告诉我,请告诉我。

使NginX根据IPv4编码基础服务于不​​同的页面

您可以访问186.215.155.54,0xBAD79B36或3134692150上的谷歌(请记住,如果你想尝试使用http://)。 浏览器如何处理基本转换? 有没有什么办法让NginX根据请求的方式从同一个IP提供不同的页面? 我知道这似乎是无用的,我可能应该使用域名/子域来做到这一点,但它可能是一个复活节彩蛋很好的伎俩。

如何让nginxlogin并删除未configuration的虚拟主机?

我有一个nginx安装服务于几个虚拟主机; 这些工作正常。 不过,我似乎记得,这台服务器负责主办一些其他网站。 我不记得哪些。 我不希望这些请求parsing为默认(任意)的虚拟主机。 目前,例如,去http://10.0.0.10/ (内部地址)parsing为默认的虚拟主机。 这个虚拟主机正在运行drupal,因为drupal不能识别虚拟主机,所以它提供了drupal安装说明。 我担心这是发生在parsing到这个服务器的其他外部名字上。 有没有办法设置nginx,以便logging和删除不完全匹配configuration的虚拟主机的请求? 或者,我猜,这个问题可能会被解释为:“我如何设置一个默认的虚拟主机来匹配所有未知的名字?我该如何configuration虚拟主机来logging和删除访问?

在一台服务器上同时使用mod_php(Apache)和php-fpm(nginx)

是否有可能在同一台服务器上使用Apache+mod_php和nginx+php-fpm ? 我知道这两个服务器不能共享相同的端口,但可以在一台服务器上运行两个不同的PHP模块吗? 我打算使用一些网站与Apache和一些与Nginx(用于性能testing)。 两者都通过YUM安装。

如何将nginx的caching文件设置为文件权限777?

我试图编写一个进程,使nginx上的caching无效(并且不会重新加热caching)。 默认情况下,nginx的caching文件有700个。 我能find的最接近的地方是: proxy_store_access user:rw group:rw all:r; 但是,这适用于代理商店,而不是caching。 那么,我该如何告诉nginx创buildcaching文件为777? 我目前在Ubuntu 12上运行nginx / 1.5.8。