Articles of nginx

在从1.4.6升级到1.8.1之后,nginx日志中的时间戳发生了变化

我在/etc/init.d/nginx设置了nginx时区: export TZ='Asia/Kolkata' 并在日志中的时间戳工作正常。 之后将nginx从1.4.6升级到1.8.1,并看到日志时间戳恢复到UTC时间戳。 有任何想法吗?

meteor应用程序403禁止

我有一个meteor应用程序,本地运行,但在我的Linux Ubuntu的Nginx和乘客networking服务器,它给出了一个403错误。 我已经改变了meteor的许可,并遵循这个简单的指南发现这个链接在ububtu 14.04 metoer设置

当重写uri时,nginx防止POST参数丢失

我想用php-fpm在nginx上做一些url重写。 也就是说,将所有请求路由到php脚本,如下所示: /index.php?fulluri=(originaluri) 许多方法来解决这个问题: Nginx – 将所有请求路由到单个脚本 https://stackoverflow.com/questions/18735657/nginx-conf-for-url-routing 任务是,做任何这些解决scheme保存POST参数和cookie以便在目标index.php脚本中稍后处理? 我觉得fastcgi_param SCRIPT_FILENAME $document_root/index.php?fulluri=$request_uri; 会工作,但我不能现在testing,想做任何修改之前有一些信息。

NGINX密码对话框不会消失

我已经使用NGINX在一个子域上启用了密码保护,并且写了一个小脚本,可以轻松添加用户。 当我input密码时,对话框消失,立即popup。 这是我的密码生成器脚本: #!/bin/bash if [ -z "$1" ] then echo "Username Expected as first param" elif [ -z "$2" ] then echo "Password Expected as second param" else htpasswd -b /home/me/.passwords $1 $2 /etc/init.d/nginx reload fi 运行: ./create-password test password 我可以看到以下输出: 为用户testing添encryption码 [ok]重新加载nginxconfiguration(通过systemctl):nginx.service。 里面/home/me/.passwords我可以看到以下条目: test:$apr1$t.LpBHkW$bEBEMK1HRBqAvvkB9cQ.I. 在我的nginxconfiguration( /etc/nginx/sites-enabled/blah )中,我有以下几点: server { listen 80; server_name blah.example.com; […]

如何代理上游服务器的顺序,并有一个限制?

我代理一个目录到websocket上游: location /Fonzy { proxy_pass http://websocket; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } 上游: upstream websocket { least_conn; server 127.0.0.1:9300; server 127.0.0.1:9301; server 127.0.0.1:9302; } least_conn将代理到具有最less连接的服务器。 我的问题是我想代理让200说连接到9300 ,然后一旦200连接已经完成,接下来的200将去9301 ,依此类推。 我发现了max_conns 属性 ,但这是商业版本。 但是,我甚至不确定这是否是一个解决scheme。

使用nginx和varnish的Django移动模板检测

我试图得到django-mobile (使用不同的模板名称空间,取决于设备types)当varnish和nginx时。 我想我已经想通了,但是用我目前的设置,似乎nginx只使用查询参数设置cookie而不是头,所以事情只有在一个额外的重新加载后才会改变。 这是如此复杂的原因是,清漆可以caching给定url的页面的两个版本(完整和移动)。 清漆configuration sub vcl_hash { hash_data(req.http.X-Flavour); hash_data(req.url); if (req.http.host) { hash_data(req.http.host); } else { hash_data(server.ip); } return (hash); } nginxconfiguration location / { # default flavour set $flavour "full"; # autodetect mobile flavour if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") { set $flavour "mobile"; } # get previously set flavour from […]

使用Nginx作为代理运行Apache的Owncloud

我目前正在运行我们自己的Owncloud(版本9)。 我已经用Apache做过好几次了,但是在使用Nginx作为代理服务器时,却遇到了麻烦。 Nginxconfiguration server { listen 443 ssl http2; server_name example.com; index index.php index.html; ssl_certificate /path/ssl.crt; ssl_certificate_key /path/ssl.key; ssl_dhparam /path/dh.pem; ssl_buffer_size 8k; ssl_session_timeout 1d; ssl_session_cache builtin:1000 shared:SSL:50m; ssl_session_tickets off; ssl_trusted_certificate /path/ssl.crt; ssl_stapling on; ssl_stapling_verify on; resolver 8.8.8.8 8.8.4.4 valid=300s; resolver_timeout 10s; add_header Strict-Transport-Security "max-age=15768000; includeSubdomains; preload"; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS'; ssl_prefer_server_ciphers on; location […]

nginx忽略根目录头(位置/)

我用http2支持自编的nginx 1.9.14: nginx version: nginx/1.9.14 built by gcc 4.9.2 (Debian 4.9.2-10) built with OpenSSL 1.0.1k 8 Jan 2015 TLS SNI support enabled 所以我有一个location = /块在我的configuration,这应该添加一个头只有当用户访问根站点( https://myserver.example.com/ )。 但是,当我在Firefox中访问我的服务器时,不会添加/ location块(这是WhereIAm )中的标头: Content-Encoding: gzip Content-Type: text/html Date: Thu, 21 Apr 2016 07:12:11 GMT Etag: W/"570bf892-363" Last-Modified: Mon, 11 Apr 2016 19:18:42 GMT Server: nginx Strict-Transport-Security: max-age=15768000; includeSubDomains; […]

由于某种原因,nginx默认错误页面停止工作

这曾经工作: server { server_name example.com; location / { proxy_pass http://localhost:8888; error_page 502 /502.html; } location = /502.html { root /var/www/example; } } 现在突然间它不再…我不知道什么改变了? 如果端口8888不响应,我得到404而不是显示/var/www/example/index.html … 如何使这个工作再次? 谢谢

Nginx的conf模板不能与dokku一起工作

我坚持下面的nginx conf模板: # Special characters – dollar signs, spaces inside of quotes, etc. – # should be escaped with a single backslash or can cause deploy failures. server { listen [::]:80; listen 80; server_name $NOSSL_SERVER_NAME; access_log /var/log/nginx/${APP}-access.log; error_log /var/log/nginx/${APP}-error.log; # set a custom header for requests # add_header X-Served-By www-ec2-01; location / { proxy_pass http://$APP; […]