Articles of nginx

Nginx fastcgi_cache排除会话cookie

需要帮助find使用Nginx fastcgi_cache而不cachingPHP会话cookie的正确设置。 这是我目前下面的。 然而,如果我进入一个已经被caching的页面,在浏览器中删除我的PHPSESSION cookie并刷新,那么testing这个,我从一个caching的Nginx文件中得到一个PHPSESSION ID。 if ($http_cookie = "PHPSESSION") { set $fastcgi_skipcache 1; } location ~* \.php { include fastcgi_params; fastcgi_pass backend; fastcgi_index index.php; fastcgi_param SERVER_NAME $host; fastcgi_param SCRIPT_URL $fastcgi_script_name; fastcgi_param SCRIPT_URI $scheme://$http_host$fastcgi_script_name; fastcgi_param SCRIPT_NAME "/index.php"; fastcgi_param PHP_SELF $uri; fastcgi_param HTTPS $https if_not_empty; fastcgi_param HTTP_FRONT_END_HTTPS HTTPS; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param REQUEST_URI $uri?$args; fastcgi_ignore_headers Cache-Control […]

为什么我的Nginx wwwredirect不工作?

我有这样的configuration: server { listen 80; server_name example.com www.example.com; return 301 https://example.fr$request_uri; } server { listen 443 ssl; root /var/www/example_v2/; index index.php index.html index.htm; server_name example.com www.example.com; return 301 https://example.fr$request_uri; } 当我进入example.com ,它将我正确地redirect到example.fr ,但是当我去www.example.com ,它并没有。 example.com和www.example.com我的DNS转到相同的IP。 有什么可能会出错? 编辑:curl ➜ ~ curl -L -I example.com HTTP/1.1 301 Moved Permanently Server: nginx/1.10.1 Date: Thu, 20 Oct 2016 11:50:38 […]

负载均衡器本身的高可用性

在互联网上关于负载平衡器本身高可用性的文章中,我们提到了一种使用虚拟IP(VIP)的方法。 在这种方法中,两个负载均衡器将保持主备模式。 活动的负载均衡器拥有VIP。 如果主动负载均衡器closures,备用负载均衡器使用一些心跳机制来检测故障并接pipeVIP,从而成为主动负载均衡器。 我的问题是: 在任何时候,只有一个负载平衡器正在提供所有请求。 如果传入请求的数量太多,会怎么样? 或者,像(HAProxy,nginx或任何硬件负载平衡器)这样的stream行负载平衡器所处理的请求数目太高而不能超过现实生活中的数量? 使用相同域名的负载均衡器集群是一个很好的select,这样DNS可以在向负载均衡器本身分配stream量时进行循环负载平衡? 通过这种方式,我们还可以通过dynamic添加或删除DNS服务器中的Alogging来实现负载均衡器的自动扩展。

cgit和nginx将索引页面作为一个存储库

我在nginx上使用cgit运行git版本库浏览器。 打开索引页面会导致显示No repositories found错误,而不是索引。 我相信这是因为foo.bar/被处理为foo.bar/cgit ,然后被解释为名称为“cgit”的git存储库,它不存在,因此是错误的。 我不知道我在这里做错了什么。 我的nginxconfiguration,与不相关的部分(如SSLconfiguration等)删除和地址/path清理匿名: server { listen 80; server_name git.foo.bar; return 301 https://git.foo.bar$request_uri; } server { listen 443 ssl http2; server_name git.foo.bar; # # ssl configs here # location ~* ^.+\.(css|png|ico)$ { root /foo/bar/htdocs; expires 30d; } location / { include fastcgi_params; fastcgi_pass unix:/foo/bar; fastcgi_index /; fastcgi_param DOCUMENT_ROOT /foo/bar/htdocs; fastcgi_param SCRIPT_FILENAME […]

如何使用Docker中的自定义configuration运行Nginx?

Nginxconfiguration有一个daemon off; 指令在/root/nginx.conf设置。 我试图在docker下使用这个命令来运行它: sudo docker run –name nginx-redirect -p 3128:3128 -v /root/nginx.conf:/etc/nginx/nginx.conf:ro -d nginx 但没有任何反应(除了容器ID的Docker输出,我认为这应该意味着一切正常),并且netstat -tulpn显示没有netstat -tulpn docker/nginx容器和没有3128端口,我错了? /root/nginx.conf : user www-data; worker_processes auto; pid /run/nginx.pid; daemon off; events { worker_connections 768; } http { server { listen 3128; location / { proxy_pass http://example.com; } } }

Nginx无法直接在同一个域上的https服务器块

我试图通过https服务使用nginx的静态文件。 build立 DNS正确地将子域指向AWS IP: subdomain1.website.com -> correct IP 工作configuration 我发现以下简单的服务器设置完全正确工作。 但是,当我修改它转发到https,失败没有错误。 # /etc/nginx/sites-available/default server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; server_name subdomain1.website.com; root /usr/share/nginx/temp-content; index index.html; location / { try_files $uri $uri/ =404; } } 试图redirect到https # /etc/nginx/sites-available/default server { listen 443 ssl; server_name subdomain1.website.com; root /home/deploy/temp-content; ssl_certificate /etc/letsencrypt/live/subdomain1.website.io/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/subdomain1.website.io/privkey.pem; ssl_protocols TLSv1 […]

通配符Cloudflare和可信证书

我想只在SSL中使用我的网站,但与cloudflare我所有的子域不受信任(我认为是因为不在“cloudflare”DNS(logging由橙色混浊))。 如果我手动添加子域名示例“test.website.com”橙色混浊SSL正常工作。 我已经订购了一个边缘证书,但没有解决我的问题。 如何在没有Cloudflare DNS(橙色混浊)的情况下在所有子域名上使用通配符SSL? (我尝试SSL“灵活”和“严格”,我已经在我的nginx上添加了证书,目前我使用“严格”的SSL)

nginx:sslvalidation失败+错误的redirect

这是我目前的nginxconfiguration: $ cat /etc/nginx/sites-enabled/bitbucket server { listen 80 default_server; listen [::]:80 default_server; server_name git.itextsupport.com bitbucket.itextsupport.com gitlab.itextsupport.com; return 302 https://git.itextsupport.com$request_uri; } server { listen 443 ssl default_server; server_name git.itextsupport.com; server_tokens off; add_header Strict-Transport-Security "max-age=31536000"; access_log /var/log/nginx/bitbucket_access.log; error_log /var/log/nginx/bitbucket_error.log; ssl on; ssl_certificate /etc/ssl/private/ssl-itextsupport.pem; ssl_certificate_key /etc/ssl/private/ssl-itextsupport.key; location / { proxy_pass http://localhost:7990/; proxy_set_header Host $host; proxy_set_header X-Forwarded-Host $host; proxy_set_header […]

无法处理与nginxcaching用户login会话

我们遇到了用户login会话的问题,这是由于nginxconfiguration文件的caching。 我们的应用程序在cakephp中开发。 用nginx不可能停止caching特定的文件。 请find下面的nginx conf文件,并build议用nginx处理用户login会话的最佳方法 用户nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /var/run/nginx.pid; 事件{worker_connections 4024; } http {include /etc/nginx/mime.types; default_type application / octet-stream; log_format main '$remote_addr – $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; #keepalive_timeout 0; keepalive_timeout 650; types_hash_max_size 2048; gzip on; gzip_disable“msie6”; gzip_vary在; […]

Nginxredirect*:端口到子域

我正在与Nginx ,我想知道如何将具有特定端口的所有请求redirect到子域? 这是我的default.conf : server{ listen 80 default_server; server_name localhost; location / { root /usr/share/nginx/html; } } server{ listen 80; server_name blog.mydomain.com; location / { proxy_pass http://my-ip:8080; } } 所以,我有默认的mydomain.com服务的HTML文件夹,和一个子域blog.mydomain.com服务的应用程序运行端口8080。 我的问题是,当我尝试直接访问my-ip:8080 ,或mydomain.com:8080或blog.mydomain.com:8080服务器服务应用程序运行端口8080,我想redirect所有这些请求到blog.mydomain.com没有:8080 blog.mydomain.com 。 我怎样才能做到这一点 ? 自动redirect到blog.mydomain.com如果我指定:8080的url?