Articles of nginx

Nginx SSL只能redirect一个特定的页面

我阅读并遵循这个问题 ,为了configurationnginx强制一个页面的SSL(admin.php为XenForo),并且它适用于一些网站pipe理员,但不是为我自己。 我想知道如果有人有任何build议,如何改善这种configuration: … ssl_certificate example.net.crt; ssl_certificate_key example.key; server { listen 80 default; listen 443 ssl; server_name www.example.net example.net; access_log /srv/www/example.net/logs/access.log; error_log /srv/www/example.net/logs/error.log; root /srv/www/example.net/public_html; location / { if ( $scheme = https ){ return 301 http://example.net$request_uri; } try_files $uri $uri/ /index.php?$uri&$args; index index.php index.html; } location ^~ /admin.php { if ( $scheme = http […]

清漆,隐藏端口号

我的设置如下: 操作系统:在OpenVZ虚拟机上运行的CentOS 6.2。 Web服务器: Nginx监听端口8080 反向代理:在端口80上听取清漆 问题在于,Varnish将我的请求redirect到端口8080,并在地址栏中显示,如http://mysite.com:8080/directory/ ,导致网站上的相关链接在请求中包含端口号(8080)从而绕过清漆。 该网站是由WordPress的。 如何让Varnish在端口8080上使用Nginx作为后端,而无需将端口号添加到地址中? 编辑:清漆是这样设置的: 我已经告诉Varnish守护进程默认听80端口。 VARNISH_VCL_CONF=/etc/varnish/default.vcl # # # Default address and port to bind to # # Blank address means all IPv4 and IPv6 interfaces, otherwise specify # # a host name, an IPv4 dotted quad, or an IPv6 address in brackets. # VARNISH_LISTEN_ADDRESS= VARNISH_LISTEN_PORT=80 # # […]

Nginx不logginghttps /:443请求

我正在尝试使用httpsconfiguration服务器,出于某种原因,似乎这些请求根本没有打到nginx。 我有一切正常工作,但一旦我去启用ssl它给了我一个将不会接受端口443(连接超时)的任何请求。 有谁知道我可以开始debugging这个问题? 我正在使用以前的服务器上使用的所有相同的逻辑。 Nginx.conf: user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { port_in_redirect off; 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; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; } […]

Mod_security日志logging

我试图运行mod_security作为独立的服务与nginx作为反向代理一切正常,除了日志logging。 mod_securitylogging反向代理ip地址,而不是客户端ip地址。 如果有人能帮忙,我将不胜感激。 以下是mod_securitylogging127.0.0.1而不是客户端IP地址的logfile示例。 2012/08/29 14:18:13 [info] 206862#0:[client 127.0.0.1] ModSecurity:访问被代码403(阶段2)拒绝。 模式匹配…

应用程序特定的环境在Nginx / Passenger中的同一台服务器上

我有两个使用Nginx / Passenger部署的Rails应用程序(比如app1和app2)。 nginx.conf中的服务器定义如下所示: server { rails_env demo; client_max_body_size 50M; listen 80; server_name localhost; root /data/apps; passenger_enabled on; passenger_base_uri /app1; passenger_base_uri /app2; } 你可以看到两者都被configuration为使用demo作为RAILS_ENV 。 我应该如何更改我的configuration以在不同的环境中运行这两个应用程序。 假设app2假设运行RAILS_ENV=qa和app1 RAILS_ENV=demo

nginx proxy_cache:限制对同一个URL的并行请求

我们使用nginx作为反向代理从上游服务器获取文件。 这些文件不是dynamic的 – 至less不是基于每个请求的 – 并且(有时)在高延迟之后。 我想限制同一个URL的请求到1。 我想避免的一个例子是: 127.0.0.1 – – [03/Jan/2013:16:08:15 +0100] "GET /part-00132.ts HTTP/1.0" 200 1506068 "-" "Prefetch" "-" 127.0.0.1 – – [03/Jan/2013:16:08:28 +0100] "GET /part-00133.ts HTTP/1.0" 200 1189476 "-" "Prefetch" "-" 127.0.0.1 – – [03/Jan/2013:16:08:29 +0100] "GET /part-00133.ts HTTP/1.0" 200 1189476 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.17 (KHTML, like […]

HTTP / 2返回奇怪的符号

所以我把我的nginx服务器转换为使用HTTP / 2,它适用于Edge和Chrome。 在IE11,但我没有得到任何回应,只有这个: View post on imgur.com 在Firefox上,页面只是拒绝redirect或加载,甚至没有错误消息。 我的SSL设置如下所示: ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH; ssl_prefer_server_ciphers on; 什么会导致这样的问题,因为我很困惑,为什么它在边缘和Chrome工作,但没有其他地方? 此外,下载文件时,我得到损坏的ZIP和BZ2,这使得它更令人困惑。 Nginx的版本是1.9.7,如果有帮助。 在此期间我已经降级到1.8.0。 🙁

Nginx反向代理到HTTPS上游获取502错误的网关?

我的目标是编写Jasmine(一个JavaScript BDDtesting框架)testing,这个testing是由一个单独的团队构build的后端API。 我有一个运行在端口9000上的Jasmine服务器。该代码发出一个以/ web /开头的相对path的AJAX请求。 我希望这些请求被引导到后端。 到目前为止,我已经得到了一个逆向代理,像这样: upstream backend { server api-dev.example.com; } server { … location / { proxy_pass http://localhost:9000; … } location /web/ { proxy_pass https://backend/web/; … } } stream量到“/”工作正常,但AJAX请求(例如,到 http://localhost:50000/web/internal?action=network-statistics )502。 我相信这是正确的端点,但有一个SSL错误。 Nginx的错误日志似乎证实了我的怀疑: 2013/12/13 16:55:28 [error] 1885#0: *257 SSL_do_handshake() failed (SSL: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol) while SSL handshaking to upstream, client: 127.0.0.1, server: […]

nginx支持.htaccess /重写规则? 与Apache的区别?

我一直在使用Apache HTTP服务器已经有相当长的一段时间了,最​​终转向静态内容服务器以及其他dynamic内容机器。 我想知道,nginx是否支持“.htaccess”文件,以及像mod_rewrite? 由于我习惯的语法,我想知道(语法)差异是什么,学习曲线是从Apacheconfiguration到nginx。

什么是“知名”文件夹?

如果在我们的日志文件中发现了一条新的错误消息,并且想知道这个.well_known -folder代表的是什么。 哪个应用程序客户端需要访问这样的文件夹以及哪个应用程序会创build 一个文件夹 ? 这里是一个域的PHP错误日志的一些代码。 (我删除了date,IP和目标域)。 0000/00/00 00:00:00 [error] 851#0: *88611 access forbidden by rule, client: xxx.xxx.xxx.xxx, server: example.com, request: "GET /.well-known/apple-app-site-association HTTP/1.1", host: "exampleA.com" 0000/00/00 00:00:00 [error] 850#0: *89749 access forbidden by rule, client: xxx.xxx.xxx.xxx, server: example.com, request: "GET /.well-known/assetlinks.json HTTP/1.1", host: "exampleA.com" 0000/00/00 00:00:00 [error] 850#0: *89767 access forbidden by rule, client: […]