Articles of nginx

如何使其他nginx服务器前面的nginx反向代理caching失效?

我在一个IP地址上运行Proxmox服务器,根据请求的主机将HTTP请求分发到容器。 我在Proxmox端使用nginx来侦听HTTP请求,并且在我的不同server块中使用proxy_pass指令来根据server_name分派请求。 我的容器在Ubuntu上运行,也运行一个nginx实例。 我在一个完全静态的特定网站上caching有麻烦:在文件更新之后,nginx会继续为我提供陈旧的内容,直到我: 清除/ var / cache / nginx /并重新启动nginx 或者 proxy_cache off此服务器的proxy_cache off并重新加载configuration 以下是我的configuration的详细信息: 在服务器(proxmox)上: /etc/nginx/nginx.conf : user www-data; worker_processes 8; pid /var/run/nginx.pid; events { worker_connections 768; # multi_accept on; use epoll; } http { ## # Basic Settings ## sendfile on; #tcp_nopush on; tcp_nodelay on; #keepalive_timeout 65; types_hash_max_size 2048; server_tokens off; # […]

NGINX – 仅影响Firefox的CORS错误

这是Nginx只影响Firefox的一个问题。 我有这个configuration: http : //pastebin.com/q6Yeqxv9 upstream connect { server 127.0.0.1:8080; } server { server_name admin.example.com www.admin.example.com; listen 80; return 301 https://admin.example.com$request_uri; } server { listen 80; server_name ankieta.example.com www.ankieta.example.com; add_header Access-Control-Allow-Origin $http_origin; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, PATCH, DELETE'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Headers' 'Access-Control-Request-Method,Access-Control-Request-Headers,Cache,Pragma,Authorization,Accept,Accept-Encoding,Accept-Language,Host,Referer,Content-Length,Origin,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; return 301 https://ankieta.example.com$request_uri; } server { server_name admin.example.com; listen […]

Nginx:如何重写User-Agent如果是空的

如何在空的时候设置User-Agent头? (例如,HTTP / 1.0) 这是我到目前为止所尝试的: set $ua $http_user_agent; if ($http_user_agent = "") //also tried = false { set $ua "Fixing-Empty-User-Agent"; proxy_pass http://$host$request_uri; } proxy_connect_timeout 2; proxy_send_timeout 10; proxy_read_timeout 10; proxy_set_header User-Agent: $ua;

在一个域下的2个ember-cli应用程序的nginx位置冲突

我正在尝试在nginx上的一个域下设置2个ember-cli应用程序。 http://example.com/ http://example.com/bar 应用程序1存储在/ var / www / foo下,而应用程序2存储在/ var / www / bar下。 一等奖的主要根目录是/ var / www / bar,并将其设置为使得/指向foo和/指向条。 这主要是为了在设置方式上的一致性。 不过,我很乐意改变设置,以使其正常工作。 我有以下nginx片段: server { listen 80; server_name www.example.com; root /var/www/bar; location /bar { root /; try_files $uri $uri/ /index.html?/$request_uri; } location / { root /var/www/foo; try_files $uri /index.html?/$request_uri; } } 我试过了,但也没有得到它的工作。 看来, location /覆盖的位置/bar/ […]

nginx无法禁用SSLv3

我有一个问题,试图禁用我的nginx安装SSLv3。 HTTPS工作正常,但我似乎无法禁用SSLv3,它使我的网站容易受到POODLE攻击。 此外,由于某些原因,即使我获得了256位证书,连接也会被encryption为128位而不是256位。 Nginx版本:1.6.2 以下是我在我想要使用的网站上的服务器块中input的内容: ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers On; ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS; 谢谢!

我安装了vestacp,但无法访问控制面板

我在aws上开始了一个新的ubuntu实例。 我跑了vesta安装: curl -O http://vestacp.com/pub/vst-install.sh bash vst-install.sh 在安装之前,我已经删除了pipe理员组,所以我不必强制安装。 在vesta设置期间,我input了我的电子邮件地址和主机名seoplay.co.uk 我得到我的login凭据,一切似乎已经正确设置,但是当我去我的www.seoplay.co.uk:8083或https://seoplay.co.uk:8083/我得到一个网页不可用。 不知道还有什么其他信息显示给你们,但这里是一个htop截图。

如何为NGINX上的默认虚拟主机提供多个SSL证书?

我在Amazon S3上有一个通过NGINX代理服务器的静态应用程序。 我使用代理的目的是允许用户将他们的域名指向我的Amazon EC2实例(通过指向custom-domain.myproduct.com CNAMElogging),以便他们可以通过自己的自定义url访问我的应用程序,如下所示: myproduct.happyclient.com 。 为了实现这一点,我有以下nginxconfiguration(为简洁起见,删除了部分): http { server { # This is my default route. References: # http://stackoverflow.com/a/15799883/91403 # http://nginx.org/en/docs/http/request_processing.html listen 80 default_server; server_name custom-domain.myproduct.com; location / { proxy_pass http://static.myproduct.com; # points to Amazon S3 proxy_set_header Host myproduct.com; } } 即使我的静态应用程序是100%公开(没有客户端的秘密,只有HTML和JavaScript),我的一些客户希望通过SSL访问它。 如何根据Host头dynamicselect使用哪个证书进行SSL连接? 请注意,我不能简单地硬编码证书path。 PS 。:客户将能够将他们的证书上传到我的实例 PS2。:这个设置已经完全适用于HTTP。 我曾经尝试过 我尝试过这样的事情,没有成功: server { listen 443 […]

nginxauthentication和自定义错误页面

我正在尝试设置我的服务器,以便在浏览域中的任何文件之前需要进行身份validation。 但是,我想显示一个自定义的错误页面( placeholder.html ),当有人无法进行身份validation。 我尝试了下面列出的服务器configuration,但它将我的浏览器发送到无限redirect循环(甚至没有提供authentication窗口)。 任何人都可以解释吗? 你将如何解决这个问题? server { listen 80; server_name example.com; root /var/www/example.com; index index.html index.htm; auth_basic "Restricted"; auth_basic_user_file /etc/nginx/auth/example.com.auth; error_page 401 placeholder.html; location = placeholder.html { auth_basic off; } location / { try_files $uri $uri/ =404; } }

nginx>清漆> hhvm

我有nginx在前端解释ssl和redirect所有非httpsstream量到https: server { listen 80; server_name example.com www.example.com; return 301 https://www.example.com$request_uri; } 从那里下一个服务器块解释ssl并传递给清漆: server { listen 443 ssl spdy; server_name example.com www.example.com; …<ssl stuff>… location / { proxy_pass http://127.0.0.1:6081; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-Port 443; proxy_set_header Host $host; proxy_redirect off; } } 我已经把所有的东西都清除掉了,以帮助debugging我的问题,因为现在它只是回传给端口8080上的nginx backend default { .host = "127.0.0.1"; […]

nginx位置和优先级(拒绝* .php忽略)

我以前是一个有点经验的阿帕奇pipe理员,但是我决定冒险尝试学习nginx。 到目前为止,一切看起来相当直观,但很明显,我还没有完全内化nginx的做法,所以我相当肯定这是一个容易解决的问题,但我似乎无法find明显的答案。 我有一个服务器,它使用php-fpm服务器的PHP,我希望通过源IP(例如:phpmyadmin,我写的一些testing脚本等)限制访问我的文档根目录中的一些子目录。 无论出于何种原因,对于目录和文件的限制似乎都可以正常工作,但FastCGI服务器提供的PHP文件显然是绕过了这种访问限制。 我已经通过在限制目录中创build不同types的testing文件来validation这种情况。 文本和HTML文件确实被拒绝,并返回一个403,但PHP文件无论其内容似乎被parsing并提供给客户端。 这里是我认为是我的网站configuration的相关部分: # pass all PHP scripts to FastCGI server socket location ~ \.php$ { # Filter out arbitrary code execution location ~ \..*/.*\.php$ {return 404;} fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_pass unix:/var/run/php5-fpm.sock; } # allow access to tools pages as necessary location ~ /tools/ { allow 10.11.12.13/32; […]