Articles of nginx

Nginx重写了多个位置

我想重写特定的位置https这里: server { listen 80; server_name mysite.com www.mysite.com; root /var/www/$server_name/public; #error_log /error.logg debug; error_page 403 /403.html; location = /403.html { allow all; } location / { #allow xxx.xxx.xxx; #deny all; index index.html index.htm index.php; try_files $uri $uri/ /index.php?$args; } 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 /register […]

使用nginx反向代理caching时,防止caching

有没有一种方法可以防止在使用nginx反向代理caching时对某些页面进行caching。 像从PHP发送一些国王头? 我的nginx版本是0.7.64 提前致谢:)

nginx http_mp4_module伪stream

我正在使用安装了http_mp4_module的Nginx 1.2.3,并尝试使用它伪造stream媒体服务器。 当我试图设置小于25的起始位置时,一切都像一个魅力: http://192.168.56.101/my_video.mp4?start=20 但是,当我开始超过25我得到错误日志中的这个错误: 2012/08/14 17:15:21 [error] 20091#0: *8 start sample is out of mp4 stss atom in "/home/bender/my_video.mp4", client: 192.168.56.1, server: localhost, request: "GET /my_video.mp4?start=25 HTTP/1.1", host: "192.168.56.101" 我testing过的所有video都有超过60秒的持续时间,所以我不认为这是因为超出了时间范围。

将请求redirect到不同的监听器nginx

我有两个听众80和777.端口80充当反向代理。 而端口777做了一些额外的东西,并希望redirect到端口80.如何redirect到Nginx的不同端口? 我正在尝试重写,但后来发现它只是用来改变path ### server{ listen 80; server_name _; location / { proxy_pass "http://upstream0;#" is included since links are not allowed in the post } } server{ listen 777; server_name _; #doing some other extra stuf //Want to redirect to port 80 under some condition } 谢谢

nginx访问日志作为JSON与查询string键值对

我想制作一个自定义的nginx访问日志,不仅是JSON,而且还有查询中每个键=值的JSON键值对。 为Nginx制作JSON日志很简单: log_format main '{' '"remote_addr": "$remote_addr",' '"remote_user": "$remote_user",' '"time_local": "$time_local",' '"request": "$request",' '"status": "$status",' '"body_bytes_sent": "$body_bytes_sent",' '"http_referer": "$http_referer",' '"http_user_agent": "$http_user_agent"' '}'; 但是可以说请求是GET /blah?foo=bar&hi=there%20mom 我在json中寻找2个额外的东西 … 'http_user_agent':'chrome', 'foo':'bar', 'hi':'there mom' } 可以这样做吗? 如果是这样,我怎么能确保生成的JSON是有效的? (解码URL转义等)。

Nginx +独angular兽子域虚拟主机失效(超时)

我在VPS上设置了一个服务器,通过Nginx + Unicorn为生产Rails应用程序提供服务。 目前这个工作正常与以下conf文件: nginx.conf unicorn.conf 但是, staging.appname.tld添加的子域最终会在/var/log/nginx/error.log产生以下错误: 2012/08/20 16:57:39 [error] 24673#0: *174 upstream timed out (110: Connection timed out) while reading response header from upstream, client: xxx.xxx.xxx.xxx, server: staging.appname.com, request: "GET / HTTP/1.1", upstream: "http://unix:/tmp/unicorn.appname_staging.sock:/", host: "staging.appname.com" 2012/08/20 16:58:17 [error] 24673#0: *178 upstream timed out (110: Connection timed out) while reading response header from […]

如何引导访问者根据他们的`主机`某些HTTP服务?

我想用nginxconfiguration来指导用户不同的Web服务。 这个场景是主机名从192.168.1.1到192.168.1.255的内部用户。我想为他们提供一些web服务,但是对于其他的外部访问者我不希望这样做。 我知道我可以使用IP_TABLES来启用这个function,但是我使用IP_TABLE规则主要是为了防火墙的目的,我不想把它和这个configuration混合在一起。 在nginx.conf有没有可用的configuration?

Nagios + NGiNX“主要脚本未知”错误

我正在尝试使用PHP-FPM获取NGiNX上的Nagios设置。 我安装了fcgiwrap ,并且能够从cgi-bin文件夹执行Perl脚本,但是当我尝试访问Nagios时,在NGiNX错误日志中出现以下错误: 2012/08/23 16:40:21 [error] 8319#0: *1 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 10.1.1.1, server: my.server.tld, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "my.server.tld" 我使用默认位置得到了同样的错误,所以我把所有东西都复制到了不同的文件夹中,以保持原始安装文件的完整性。 cp -R /usr/lib/cgi-bin/nagios3 /var/www/cgi-bin cp -R /usr/share/nagios3/htdocs /var/www/html 这是我在/etc/nginx/sites-available/default server { listen 80; server_name my.domain.tld; access_log /var/log/nginx/my.domain.tld.access.log; error_log /var/log/nginx/my.domain.tld.error.log; index index.php […]

lighttpd的+阿帕奇

所以最近我听说有人在一起运行apache和nginx,nginx是静态内容,apache是​​dynamic的。 同样可以使用lighttpd和apache来完成吗?

nginx:502使用node.js varnish和stunnel的时候坏了网关

我一直在关注这个教程 ,除了我的nginx设置,一切似乎都运行正常。 我的node.js应用程序在端口1337上运行,varnish在端口80上运行,443上的stunnel和8080上的nginx。 当我指定端口https://example.com:1337时,我可以正确地到达我的应用程序,但访问https://example.com时得到的是502 Bad Gateway错误。 这是我的nginx日志的输出: 2012/08/25 14:13:59 [error] 6049#0: *1 no live upstreams while connecting to upstream, client: 127.0.0.1, server: example.com, request: "GET / HTTP/1.1", upstream: "http://app_example/", host: "example.com" 2012/08/25 14:14:02 [error] 6049#0: *1 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: example.com, request: "GET / HTTP/1.1", upstream: […]