Articles of nginx

Nginxredirect:文件夹到外部域

我正在尝试将domain1.com/blog/$redirect到domain2.com/$。 如何编辑这个从redirect去除/博客? location /blog { rewrite ^/(.*) http://domain2.com/$1 break; } 它现在redirectdomain1.com/blog/blabla到domain2.com/blog/blabla(所以博客仍然存在)..在此先感谢!

无论如何,使用memcached与Nginx的发布请求?

2.1,我也使用亚马逊弹性caching服务(它是一个memcached服务器) Nginx具有一个聪明的function,使用memcached进行常见的获取请求,但是如果是post请求不使用memcached,是不pipe怎样禁用此function? 这是我的configuration; location /{ set_md5 $memcached_key "http://$server_name$uri"; memcached_pass cacheviews.bsd7na.0001.use1.cache.amazonaws.com:11211; default_type text/html; add_header Content-Encoding gzip; error_page 405 404 = @fallback; } location @fallback{ internal; gzip_types text/css text/plain application/atom+xml application/x-javascript; gzip_vary on; # stuff to do a normal render of the page }

在ubuntu上用nginxconfigurationvsftpd

我在Ubuntu 12.04LTS上安装了vsftpd,以及Amazon EC2实例上的nginx,php和sql。 networking服务器是很好的去,但我无法连接到FTP服务器。 我不太清楚如何设置权限或我可能会丢失什么configuration选项。 默认情况下,Web根目录的位置在/usr/share/nginx/www ,它由root:root拥有。 Web服务器在组www-data以用户www-data运行。 我打开了端口21,并在ec2后端和ufw防火墙中设置被动端口。 在vsftpd.conf中,我有: … anonymous_enable=NO local_enable=YES local_umask=0027 chroot_local_user=YES pasv_enable=YES pas_max_port=12100 pasv_min_port=12000 port_enable=YES … 现在,我不确定如何创buildFTP用户,当我login时,显示我的Web目录与写权限。 我已经尝试了几种不同的方式,但是我一直在遇到错误(无论是否连接,没有写入权限,或超时时间很慢)。

安全地禁用Nginx的编译选项(仅用作反向代理/caching时)

我已经读过,我可以做到这一点,以作为静态内容caching/反向代理时使用较小的脚本Nginx: –without-mail_pop3_module –without-mail_imap_module –without-mail_smtp_module 还有哪些其他选项可以安全地禁用? SSI,FastCGI? 其他? 反向代理的唯一要求是能够执行https和gzip压缩。 将禁用所有的模块真的帮助足迹和/或性能?

X-Real-IP头在负载平衡器后面用nginx填满

我们有两个networking服务器(nginx)位于负载平衡器后面(风暴点播负载平衡器,而不是由我们的团队pipe理)。 默认情况下,我们收到的IP是负载均衡器IP。 我们尝试在nginx中使用真实的ip模块,但是看起来负载均衡器并没有转发真实的ip。 Nginx的configuration(我们有一个默认的虚拟主机,只是redirect到一个静态的HTML页面进行testing,并inheritance了一切从http指令): http { # xxxx is the IP of the load balancer set_real_ip_from xxxx; real_ip_header X-Real-IP; # also tried: #real_ip_recursive on; #set_real_ip_from xxx0/24; #set_real_ip_from 0.0.0.0:0; log_format main '$remote_addr – $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_real_ip" "$http_x_forwarded_for"'; Nginx的版本和编译模块: nginx -V nginx version: nginx/1.2.1 built by gcc 4.4.4 20100726 (Red […]

我如何使用我自己的网页forms与ngx_http_auth_basic_module?

我想用我自己的forms捕获用户名和密码,然后使用Nginx的ngx_http_auth_basic_module这些值,而不是默认的Nginx框出现,要求用户名和密码? 我知道如何创build表单,这不是我的问题的一部分。

与passthru在php中意外的行为

我已经在Ubuntu的12.04上设置了nginx和php。 我有以下的PHP文件: <?php echo "Hello "; echo passthru("cat /proc/meminfo"); echo "world. I am "; echo passthru("whoami"); ?> 从命令行运行时,这种方式是完全正常的,php从/ proc / meminfo中返回文本。 当通过nginx运行,但是,我看到这样的: Hello world. I am www-data 显然,passthru正在工作。 但是,我似乎无法读取任何/ proc。 / proc的权限是dr-xr-xr-x,我已经确认nginx和php运行的www-data用户可以访问那个目录。 我打开了PHP日志logging,并没有与此相关的错误消息。 build议? 编辑:安全模式closures。

对于SSL和非SSL页面使用nginx / varnish

免责声明:我发布了这个在Stackoverflow以及我认为它可能有适合更好的。 如果有人想在那里回答的话,下面的问题链接如下。 – 我有以下几点: domain.com – 很多不需要SSL的URL(我想用varnish来caching所有这些)domain.com/shop – 所有的URL都应该使用SSL(不需要清漆,我想在端口上听443) 我基本上是寻找configuration服务器来caching所有不需要SSL的uris的最佳方法,因为这必须在端口443上运行。所有端口8080请求都将变为Varnish并正常工作。 另外我想确保和非ssl请求被发送到domain.com(包括www请求)。 我之前做过这个,但由于某种原因,等式中的SSL使事情变得复杂。 我的configuration如下: `server { listen 8080; server_name domain.com; root /var/www/domain.com/public_html; index index.html index.htm index.php; location / { try_files $uri $uri/ /index.php?q=$uri&$args; } location ~ \.php$ { fastcgi_buffers 8 256k; fastcgi_buffer_size 128k; fastcgi_intercept_errors on; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass unix:/dev/shm/php-fpm-www.sock; # Tried using to […]

上传超时(110:连接超时)与nginx + Tomcat + Amazon EC2

在Amazon EC2实例上,我们运行了nginx和Tomcat。 Nginx将在同一实例上运行的端口8080上的所有对Tomcat的请求进行代理。 这一天工作正常,但后来开始看到很多upstream timed out (110: Connection timed out)在nginx日志中的错误,该网站是无法访问。 现在Tomcat可以在8080端口访问。所以这个问题似乎在nginx和Tomcat之间。 这是nginx.conf样子, worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; server { listen 80; server_name domainname.com; rewrite ^/(.*) http://www.domainname.com/$1 permanent; } server { listen 80; server_name www.domainname.com; location / { proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass […]

将后端压缩到nginx反向代理数据的最佳方式是什么?

我们将运行一个nginx反向代理,它将通过Internet从后端获取数据。 我们的意思是通过互联网的后端机器将不会在前面向反向代理的LAN上。 我们认为在将这些请求通过互联网发送之前,可以很好地处理这些请求。 我看到它的方式应该是这样的: 客户端使用accept-encoding标头或gzip请求内容。 反向代理将其发送到后端服务器。 后端压缩此内容,因为gzip的接受编docker被发送。 请求发送一路上压缩的链。 我们都可以做得很直接。 我的问题是,如果我们在nginx反向代理端启用了gzip压缩,这将如何工作? Nginx会尝试gzip已经gzip的内容吗? 希望这是有道理的。 谢谢。 更新1: 我了解caching已经(和这个服务)gzipped内容的影响。 我们将修改caching键以包含accept编docker,从而根据用户代理可以接受的内容提供(caching)正确压缩/未压缩的内容。