Articles of nginx

Nginx,检查请求方法,而不使用IF?

我想优化我的Nginxconfiguration,但遇到了一个问题,我不知道如何解决。 我有一个文件夹/images在我的服务器上,我为网站提供各种静态文件。 虽然也使用相同的文件夹,以通过WebDAV上传文件。 因此,我必须检查每个请求是否存在静态文件,如果请求方法是GET ,则传递该文件。 否则,我假设请求与WebDAV(如PUT等)有关。 看到这个例子: if ($uri ~* ^/images) { set $getimages "${getimages}A"; } if ($request_method = GET) { set $getimages "${getimages}B"; } if ($getimages = "AB") { rewrite ^ $uri$args last; } 这上面的示例工作正常。 但我想知道是否有另一种方法来做到这一点,而不使用IF。 鉴于Nginx Wiki中的IfIsEvil参考 想法任何人?

如何添加nginxfile upload模块到Debian Squeeze?

我需要在我的Debian Squeeze服务器中使用nginx上传模块。 我已经安装了nginx和nginx-extras。 nginx版本是1.4.2。 从nginx-extras的包描述中,似乎应该包含上传模块,然而nginx -V给了我这个列表: nginx version: nginx/1.4.2 TLS SNI support enabled configure arguments: –prefix=/usr/share/nginx –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-client-body-temp-path=/var/lib/nginx/body –http-fastcgi-temp-path=/var/lib/nginx/fastcgi –http-log-path=/var/log/nginx/access.log –http-proxy-temp-path=/var/lib/nginx/proxy –http-scgi-temp-path=/var/lib/nginx/scgi –http-uwsgi-temp-path=/var/lib/nginx/uwsgi –lock-path=/var/lock/nginx.lock –pid-path=/var/run/nginx.pid –with-pcre-jit –with-debug –with-file-aio –with-http_addition_module –with-http_dav_module –with-http_flv_module –with-http_geoip_module –with-http_gzip_static_module –with-http_gunzip_module –with-http_image_filter_module –with-http_mp4_module –with-http_perl_module –with-http_random_index_module –with-http_realip_module –with-http_secure_link_module –with-http_stub_status_module –with-http_ssl_module –with-http_sub_module –with-http_xslt_module –with-ipv6 –with-mail –with-mail_ssl_module –add-module=/usr/src/nginx/source/nginx-1.4.2/debian/modules/headers-more-nginx-module –add-module=/usr/src/nginx/source/nginx-1.4.2/debian/modules/nginx-auth-pam –add-module=/usr/src/nginx/source/nginx-1.4.2/debian/modules/nginx-cache-purge –add-module=/usr/src/nginx/source/nginx-1.4.2/debian/modules/nginx-dav-ext-module –add-module=/usr/src/nginx/source/nginx-1.4.2/debian/modules/nginx-development-kit –add-module=/usr/src/nginx/source/nginx-1.4.2/debian/modules/nginx-echo –add-module=/usr/src/nginx/source/nginx-1.4.2/debian/modules/ngx-fancyindex […]

无法与Vagrant主机的nginx进行通信

我使用Ansible在Vagrant框中编译和configurationNginx。 如果我从框中运行curl http://localhost/ ,我得到预期的响应( phpinfo() )。 如果我从我的Mac主机访问URL http://testapp:8080/ ,那么我无法连接。 我的configuration如下: HOST:/ etc / hosts 192.168.100.10 testapp 主持人:vagrantfile Vagrant.configure("2") do |config| config.vm.define "web" do |web_config| web_config.vm.box = "raring64" web_config.vm.box_url = "https://dl.dropboxusercontent.com/s/{{redacted}}/raring64.box" web_config.vm.network "forwarded_port", guest: 80, host: 8080 web_config.vm.network "private_network", ip: "192.168.100.10" web_config.vm.provision :ansible do |ansible| ansible.playbook = "devops/webserver.yml" ansible.hosts = "webservers" ansible.inventory_file = "devops/hosts" ansible.verbosity = […]

在Apache升级后Remote_Addr不起作用

我刚刚从apache2.2升级到apache2.4,suddly Remote_Addr打印127.1.1.0,而不是客户端IP。 我有apache行为nginx与以下设置: proxy_pass http://127.0.0.1:8080; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_connect_timeout 60; proxy_send_timeout 60; proxy_read_timeout 60;

为什么nginx不响应域名?

我有nginx与以下vhosts: 一个gitlab虚拟主机: server { listen 443; server_name gitlab.mydomain.com; # eg, server_name source.example.com; server_tokens off; # don't show the version number, a security best practice root /home/git/gitlab/public; ssl on; ssl_certificate /etc/nginx/ssl/gitlab.crt; ssl_certificate_key /etc/nginx/ssl/gitlab.key; … # individual nginx logs for this gitlab vhost access_log /var/log/nginx/gitlab_access.log; error_log /var/log/nginx/gitlab_error.log; … } 默认虚拟主机来捕获所有其他域名 server { listen 80; return 444; } […]

Uwsgi从根开始,但不作为服务

我有nginx + uwsgi设置烧瓶网站。 那是我的nginx server { listen 80; server_name _; location /static/ { alias /var/www/site/app/static/; } location / { uwsgi_pass 127.0.0.1:5080; include uwsgi_params; } } 这是我的uwsgi config.xml <uwsgi> <socket>127.0.0.1:5080</socket> <autoload/> <daemonize>/var/log/uwsgi_webapp.log</daemonize> <pythonpath>/var/www/site/</pythonpath> <module>run:app</module> <plugins>python27</plugins> <virtualenv>/var/www/venv/</virtualenv> <processes>1</processes> <enable-threads/> <master /> <harakiri>60</harakiri> <max-requests>2000</max-requests> <limit-as>512</limit-as> <reload-on-as>256</reload-on-as> <reload-on-rss>192</reload-on-rss> <no-orphans/> <vacuum/> </uwsgi> 当我试图启动uwsgi服务( service uwsgi start )它说好,但没有uwsgi进程,我在日志中看到以下内容: *** Starting uWSGI […]

在Ubuntu上安装NginX,并找不到新的WWW根目录

在Ubuntu 13.04上原来的WWW是在/ var / www /然后我安装了NginX,它安装正确,但是我找不到可以通过http访问的实际文件夹(我在/ etc / nginx /中查到)。 我search了index.htm,index.html和index.php,但有数百个结果。 有一个命令,我可以运行告诉我什么文件夹http指向? 我试图寻找这个,但我不知道要使用什么关键字。 我看过的地方: /usr/share/nginx/www /usr/share/www /usr/share/html /var/www /etc/nginx/

nginx php5-fpm“文件未find” – FastCGI在stderr中发送:“主脚本未知”

所以我试图在debian wheezy服务器上第一次运行php5-fpm的nginx web服务器 打一个PHP文件显示简单的File not found 我已经做了研究(实际上浪费了很多时间),有很多人有类似的问题,但我没有成功地纠正它与他们的工作。 我仍然有同样的错误: $ tail /var/log/nginx/access.log /var/log/nginx/error.log /var/log/php5-fpm.log | less ==> /var/log/nginx/error.log <== 2013/10/26 21:36:00 [error] 6900#0:* 1971 FastCGI在stderr中发送:“主脚本未知” ,从上游读取响应头时, 我已经尝试了很多东西,很难记住什么。 我已经把我的configuration文件在github上 我的/etc/nginx/nginx.conf 我的/etc/php5/fpm/php-fpm.conf 目前,nginx.confconfiguration使用这个… server { server_name mydomain.tld; root /srv/data1/test; location ~ \.php$ { try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } /etc/php5/fpm/pool.d/www.conf包含listen […]

NGINX SSL证书不能使用

我一直在研究SSL的东西,并从4个教程得到无处…我已经买了一个SSL的pingrglobe.com,现在试图将其应用到我的服务器。 这是我的nginx代码: http { server { listen 80; server_name pingrglobe.com; rewrite ^(.*) http://www.pingrglobe.com$1 permanent; } server { listen 443; ssl on; ssl_certificate /etc/nginx/ssl/pingrglobe.crt; ssl_certificate_key /etc/nginx/ssl/pingrglobe.key; #enables SSLv3/TLSv1, but not SSLv2 which is weak and should no longer be used. ssl_protocols SSLv3 TLSv1; #Disables all weak ciphers ssl_ciphers ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM; server_name www.pingrglobe.com; root /var/www/pingrglobe.com; index index.html index.php; […]

Nginx将所有不匹配文件的请求redirect到一个php文件

我试图获得所有请求: http://example.com/downloads/* : http://example.com/downloads/*redirect到http://example.com/downloads/index.php除非请求的文件存在于/downloads/ 例如: http://example.com/downloads => /downloads/index.php http://example.com/downloads/unknowfile => /downloads/index.php http://example.com/downloads/existingfile => /downloads/existingfile 我目前的问题是我有redirect到PHP工作,但静态文件没有送达或相反。 这是我目前的虚拟主机conf :(redirect罚款,但静态文件发送到PHP和失败) server { listen 80; ## listen for ipv4; this line is default and implied server_name domain.com; root /data/www; index index.php index.html; location / { try_files $uri $uri/ /index.html; } error_page 404 /404.html; # redirect server error pages to […]