Articles of nginx

运行Nginx作为gunicorn和apache2的反向代理

我想用nginx作为apache和gunicorn的反向工具 location /应该由apache处理 location /webapps/应该由gunicorn处理 upstream gfbu_app_server { server unix:/webapps/gfbu/run/gunicorn.sock fail_timeout=0; } server { listen 80; server_name eu-con.gfbu; client_max_body_size 4G; access_log /webapps/gfbu/logs/nginx-access.log; error_log /webapps/gfbu/logs/nginx-error.log; location /static/ { alias /webapps/gfbu/gfbu/static/; } location /media/ { alias /webapps/gfbu/gfbu/media/; } location /webapps/ { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://gfbu_app_server; break; } […]

Nginx重写ngx_http_index_module目录索引处理

Nginx v 1.4.6 autoindexclosures; 在没有中心路由端点的应用程序中,对于没有索引*的结构中的目录,我想要外部redirect,而不是403 Forbidden或内部redirect。 app-root/ app-core/ config/ lib/ modules/ templates/ index.php 鉴于上述情况,如果没有任何app-core / lib / modules / templates /具有索引*,且没有server { location {}}configuration覆盖,则对它们的任何请求都会导致402禁止响应。 令人讨厌。 有了这个configuration,我可以在内部redirect到一个实际的索引。 location ~* ^/(app-core|config|lib|modules|templates)/$ { index /; } 因此,对http://localhost:xxxx/lib/的请求将服务于上面显示的app-root / index.php。 够公平的,但我认为这可能会更好。 我宁愿发出一个303 见其他和redirect到http://localhost:xxxx/但我不知道如何使其工作。

Nginx多网站多公网ip

我已经部署了archetecture的平台,我有nginx lb服务器哈希,后面是有4个应用程序的应用程序服务器。 nginx lb服务器具有如下configuration: 上游example1.com {ip_hash; 服务器10.10.10.10; 服务器10.10.20.10} 上游example2.com {ip_hash; 服务器10.10.10.11; 服务器10.10.20.11} 所以它代理私人IP的服务器。 我的问题是,每个应用程序如何获得专用的公共IP地址? 我的代理服务器有4个IP地址,我想把每个地址指向每个应用程序。 谢谢!

如何在不redirect的情况下将子域CNAME别名添加到其他域子域?

我有两个领域,我拥有两个领域。 domain1.com和domain2.com 在domain2.com我有一个子域my.domain2.com有一个DNS指向一个nginx。 我希望other.domain1.com在不redirect的情况下查看my.domain2.com中的内容。 我做的是从other.domain1.com设置一个CNAME到my.domain2.com但是当我进入访问它redirect到my.domain2.com而不是显示我的内容。 这是从DNS设置还是nginx应该设置不同?

在NGINX和PHP-FPM升级之后,PHP停止工作,并且没有任何错误

PHP-FPM正在运行,NGINX正在运行。 NGINX确实读取了PHP-FPM的套接字​​。 我停止PHP-FPM,我得到了错误的网关错误。 但是,什么都不显示。 我已经检查了nginx / error.log和php5-fpm.log,并且没有错误。 我更改了PHP-FPM中的日志logging以查看正在发生的事情,并根据需要创buildsubprocess(pm = ondemand)。 这是我的php-fpm.conf: pid = /var/run/php5-fpm.pid error_log = /var/log/php5-fpm.log log_level = debug include=/etc/php5/fpm/pool.d/*.conf pool.d / www.conf(那里唯一的文件)[www] user = www-data group = www-data listen=/var/run/php5-fpm.sock listen.owner=www-data listen.group=www-data pm=ondemand pm.max_children=4 pm.start_servers=2 pm.min_spare_servers=1 pm.max_spare_servers=3 chdir=/ 这里是nginx.conf user www-data www-data; worker_processes 4; pid /run/nginx.pid; events { worker_connections 768; } http { client_max_body_size […]

ELK堆栈:无法加载Kibana 4

我已经按照这个指南安装了Elasticsearch,Logstash,Kibana和Nginx,我使用了最新的版本。 https://www.digitalocean.com/community/tutorials/how-to-install-elasticsearch-logstash-and-kibana-4-on-ubuntu-14-04 问题是,当访问Web服务器时,它说: Kibana正在加载。 在这里给我一点时间。 我正在加载一大堆代码。 别担心,所有这些好东西都会被下次caching! 但是它从不加载Kibana的开始页面。 当我尝试http:// server-ip:5601我得到一个 ERR_CONNECTION_REFUSED 但似乎加载curl: elk-stack:/opt/kibana/bin$ curl -i 0:5601 HTTP/1.1 200 OK X-App-Name: kibana Accept-Ranges: bytes Cache-Control: public, max-age=0 Last-Modified: Tue, 21 Jul 2015 09:46:14 GMT ETag: W/"6f9-14eb001a270" Content-Type: text/html; charset=UTF-8 Content-Length: 1785 Vary: Accept-Encoding Date: Wed, 22 Jul 2015 16:07:09 GMT Connection: keep-alive <!DOCTYPE html> <!–[if IE […]

在过期的SSL证书上遇到麻烦

我在一家非常知名的公司重新申请了SSL证书,他们搞砸了我的订单。 在被纠正之后,我收到了几个没有说明的证书文件: MY.SERVER.COM.crt OV_ThatCompanyOVServerCA2.crt AddTrustExternalCARoot.crt OV_USERTrustRSACertificationAuthority.crt 所以我记得我需要将它们连接在一起。 我这样做,但谁知道我是否有正确的顺序,因为我在Google上发现了数千条相互矛盾的指令。 我在我的nginx服务器上安装了证书。 然后我得到这个: nginx: [emerg] SSL_CTX_use_PrivateKey_file("/usr/nginx/conf/myserver.key") failed (SSL: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch) 嗯,哦。 这次我没有.key文件。 我所拥有的是: privkey.pem myserver.csr 所以旧的密钥文件不起作用。 我试图replaceprivkey.pem文件并得到这个: Enter PEM pass phrase: 那么谁知道那是什么 我不认为我创build了一个密码短语。 我不知道下一步该怎么做。 如何生成一个可以工作的密钥文件?

操作.conf文件以正确重写https

我有一个nginx服务器和一个域example.com。 每个客户都有他自己的子域名,比如wsb.example.com等。他们的内容通过PHP更改,但所有子域名都被redirect到Web服务器上的相同文件夹。 我遇到的唯一问题是访问没有HTTPS的域名。 https://whatever.example.com/正常工作,但whatever.example.com会将我redirect到https://*.example.com/ 我究竟做错了什么? server { listen *:80; listen *:443 ssl; server_name *.alterament.de; index index.php; root /var/www/webapp.alterament.de/public; ssl_certificate ssl/alterament.de.crt; ssl_certificate_key ssl/alterament.de.key; if ($ssl_protocol = "") { rewrite ^/(.*) https://$server_name/$1 permanent; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location /resources { root /var/www/webapp.alterament.de; } }

Nginx:/etc/nginx/nginx.conf中不允许使用“location”指令:14

Iam面对这个错误, 启动nginx:nginx:[emerg]“location”指令在/etc/nginx/nginx.conf中不允许:14 nginx:configuration文件/etc/nginx/nginx.conftesting失败 这是我的nginx.conf文件: user www-data; worker_processes 4; pid /var/run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { limit_conn_zone $binary_remote_addr zone=connlimit:10m; location /downloads { limit_conn connlimit 1; limit_rate 512k; } ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect […]

将subdomain.domain.comredirect到www.subdomain.domain.com

我们目前有一个通配符虚拟主机接受所有的域名请求。 我想redirectsubdomain.domain.com到www.subdomain.domain.com所以我的通配符将回答 有一个例外,我不想将www.domain.comredirect到www.www.domain.com 如何实现? 我放在一起(在通配符块之外),但它不处理exception,并不确定variables的事情 if ($http_host ~ (.*).domain.com) { set $test P; } if ($http_host != www.domain.com) { set $test "${test}C"; } if ($http_host != www.*.domain.com) { set $test "${test}D"; } if ($test = PCD) { rewrite ^(.*)$ www.%1.domain.com$1 permanent; } 谢谢