Articles of nginx

在nginx中添加和使用头文件(HTTP)

我使用两个系统(都是nginx负载均衡器和一个作为备份)。 我想添加和使用less量http自定义标题。 请给出你的build议 例如 upstream upstream0{ #list of upstream servers server backend:80; server backup_load_balancer:777 backup; #healthcheck } server{ listen 80; #Add custom header about the port and protocol (http or https) server_name _; location / { proxy_pass "http://upstream0;#" is included since links are not allowed in the post } } //备份系统 server{ listen 777; server_name […]

nginx反向代理到mongodbrest界面

我正在尝试使用代理MongoDB的REST接口的HTTPvalidation来设置反向代理。 到目前为止,我有这样的: server { listen 80; server_name tld.example.com; charset utf-8; access_log /home/jill/logs/nginx.access.log main; # Redirect all HTTP traffic to HTTPS URL rewrite ^(.*) https://tld.example.com$1 permanent; } server { listen 443; server_name tld.example.com; ssl on; ssl_prefer_server_ciphers on; ssl_protocols TLSv1 SSLv3; ssl_ciphers HIGH:!ADH:!MD5:@STRENGTH; ssl_session_cache shared:TLSSL:16m; ssl_session_timeout 10m; ssl_certificate /path/to/cert/tld.example.com.bundle.crt; ssl_certificate_key /path/to/cert/tld.example.com.key; gzip on; gzip_vary on; gzip_comp_level 6; […]

Nginx + SSL服务器没有响应

我正在将一些站点从Apache迁移到Nginx,并尝试将其中一个configuration为应答SSL请求。 目前我得到一个服务器没有响应的错误。 如果我切换到80端口,我得到一个nginx错误(不担心错误本身,因为nginx至less服务)。 对于这个网站,我希望它只回答ssl请求。 这是服务器块的样子: server { listen 443; server_name dev.project.mydomain.net; root /opt/dev/project-root; index index.php; ssl on; ssl_certificate /etc/ssl/certs/mycert.crt; ssl_certificate_key /etc/ssl/certs/mycert.pem; access_log /var/log/nginx/vh.dev-project.access.log; error_log /var/log/nginx/vh.dev-project.error.log; location /aliasing/ { alias /opt/dev/project-root/aliased; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; […]

Nginx重写:使用参数从URL中移除.html

如何从参数中删除一个url的.html? 例如: http : //www.domain.com/somepage.html?argument= whole& bunch=a-lot 至: http://www.domain.com/somepage?argument=whole&bunch=a-lot 我努力了 location / { index index.html index.php; rewrite ^\.html(.*)$ $1 last; try_files $uri $uri/ @handler; expires 30d; ## Assume all files are cachable } 和一堆其他的build议,但似乎无法使其工作…. TNX

stream浪/厨师 – nginx食谱延伸

我对厨师的使用相当陌生,特别是对于stream浪汉来说,这对于那些更有经验的用户来说很可能是一个愚蠢的问题。 我正在使用这本食谱: https : //github.com/opscode-cookbooks/application_nginx 我只是想添加我自己的网站configuration(虚拟主机)。 它必须是以下之一: 将我自己的收件人和模板直接添加到食谱中 创build我自己的食谱,以某种方式扩展nginx食谱,只添加我需要的特定行为。 选项1对我来说看起来不太合适,我不知道如何完成选项2,而不必完全分开食谱。 任何人都可以build议如何实现?

nginx – 哪种方式更好地redirect和为什么

我想从www.mydomain.comredirect到nginx中的domain.com。 我search互联网,发现有两种方法: 第一种方式 server { listen 80; server_name www.domain.com; rewrite ^/(.*) http://domain.com/$1 permanent; } 第二种方式 server { listen 80; server_name www.domain.com; return 301 $scheme://domain.com$request_uri; } 两种方式都有效 但是我应该使用哪一个,为什么?

nginx error_log报告“bind()为0.0.0.0:80失败(48:地址已经在使用)”

我最近通过OS X 10.9 Mavericks上的MacPorts安装了nginx和PHP-FPM,虽然它工作正常,但是我的主要error_log连续说80端口正在使用中。 2013/10/25 11:27:36 [emerg] 4510#0: bind() to 0.0.0.0:80 failed (48: Address already in use) 2013/10/25 11:27:36 [notice] 4510#0: try again to bind() after 500ms 2013/10/25 11:27:36 [emerg] 4510#0: bind() to 0.0.0.0:80 failed (48: Address already in use) 2013/10/25 11:27:36 [notice] 4510#0: try again to bind() after 500ms 2013/10/25 11:27:36 [emerg] 4510#0: bind() […]

Nginx,安装https

我试图在我的ubuntu服务器上用NGINX ver 1.4.7和Phusion Passenger 4.0.41来设置https。 我使用这两个命令创build了.key和.csr sudo openssl genrsa -des3 -out server.key 2048 sudo openssl req -new -key server.key -out server.csr 并发送.csr到sslshopper.com家伙 有3个文件: Root CA Certificate – AddTrustExternalCARoot.crt Intermediate CA Certificate – USERTrustSecureServerCA.crt Your COMODO SSL Certificate – subdomain_domain_com.crt 这就是我的nginx.conf现在的样子 http { passenger_root /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.41; passenger_ruby /usr/local/rvm/gems/ruby-2.1.1/wrappers/ruby; server_names_hash_bucket_size 64; include mime.types; default_type application/octet-stream; #access_log logs/access.log main; […]

减lessGitlab内存占用

目前,我正在运行一个Gitlab实例(v6.7.3)和一个DigitalOcean VPS上的Ghost -powered个人博客,其中512mb(最低端)由nginx提供 。 直到最近我都无法运行,因为Gitlab未能开始,抱怨内存不足。 我通过在VPS(1GB)上启用交换来解决问题(至less是暂时的)。 主要的问题似乎是,Gitlab产生了Sidekiq的25(!)个实例,每个实例占用我记忆的30%,如htop所示。 我在SF上发现了一个关于configurationGitlab使用较less的Sidekiq工作者的问题,但是没有得到一个被接受的回应。 我的问题是:用最低的内存占用量运行Gitlab的configuration是什么? 也许我不能减less这25名Sidekiq工作人员,但我可以做一些其他的工作来减less内存占用。 我的VPS仅供私人使用,我的Gitlab上有5或6个项目,每天最多需要5或6次提交,所以实际运行的最轻的configuration对我来说已经足够了。 我的博客也很less有点击。

nginx作为负载平衡器:它可以返回到客户端的请求被发送到哪个应用服务器?

正常的解决方法是调整应用程序服务器自身,将自己的身份发回自定义的http头中。 我们处于特殊情况,应用程序服务器是一个硬编码的应用程序,我们似乎无法获得新的版本。 (在apache或iis上很容易解决,我们只需将这个头添加到web服务器。) 所以问题是,nginx本身是否具有向响应中添加头的function,以通知客户端哪个服务器为请求提供服务? 注意:这不是一个正常的“浏览器到Web服务器”的情况。 这是一个自定义的客户端代码(我们有源代码,可以修改)在整体的,编译的服务器(我们没有源代码也不能修改)上运行REST API。 客户端需要知道它打的是哪个服务器,但是不需要(或者不需要)一遍又一遍地去同一台服务器(例如,cookies不是答案….没有cookie)。 客户端只需要能够在响应中看到哪个服务器服务该请求的指示。 我们的nginxconfiguration如下。 我们正在运行当前的GA版本。 我们目前正在运行nginx作为一个负载平衡器,并在Windows上。 upstream appserver { least_conn; server 192.168.104.53:1124; // these are the IPs and ports of actual app servers server 192.168.104.51:1124; server 192.168.104.59:1124; } server { listen 80; // this is where nginx listens server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_pass […]