Articles of nginx

访问日志中的NGINx – 301 HTTP错误

这个问题可能与此有关: https : //stackoverflow.com/questions/39097554/how-do-i-prevent-code-injection-attack-on-nginx – 虽然我的问题有点不同。 此外,这个问题似乎是相似的,虽然要求不同的事情: 在Ubuntu 14.04上通过Nginx的奇怪的URL请求,恶意用户试图做什么? 我在我的nginx access.log中出现了奇怪的日志行: xxx.xxx.xxx.xxx – – [24/Aug/2016:05:49:59 +0100] "POST //%63%67%69%2D%62%69%6E/%70%68%70?%2D%64+%61%6C%6C%6F%77%5F%75%72%6C%5F%69%6E%63%6C%75%64%65%3D%6F%6E+%2D%64+%73%61%66%65%5F%6D%6F%64%65%3D%6F%66%66+%2D%64+%73%75%68%6F%73%69%6E%2E%73%69%6D%75%6C%61%74%69%6F%6E%3D%6F%6E+%2D%64+%64%69%73%61%62%6C%65%5F%66%75%6E%63%74%69%6F%6E%73%3D%22%22+%2D%64+%6F%70%65%6E%5F%62%61%73%65%64%69%72%3D%6E%6F%6E%65+%2D%64+%61%75%74%6F%5F%70%72%65%70%65%6E%64%5F%66%69%6C%65%3D%70%68%70%3A%2F%2F%69%6E%70%75%74+%2D%64+%63%67%69%2E%66%6F%72%63%65%5F%72%65%64%69%72%65%63%74%3D%30+%2D%64+%63%67%69%2E%72%65%64%69%72%65%63%74%5F%73%74%61%74%75%73%5F%65%6E%76%3D%30+%2D%64+%61%75%74%6F%5F%70%72%65%70%65%6E%64%5F%66%69%6C%65%3D%70%68%70%3A%2F%2F%69%6E%70%75%74+%2D%6E HTTP/1.1" 301 178 "-" "-" 所以如果我把整个这个URL和解码它,我得到这个: //cgi-bin/php?-d allow_url_include=on -d safe_mode=off -d suhosin.simulation=on -d disable_functions="" -d open_basedir=none -d auto_prepend_file=php://input -d cgi.force_redirect=0 -d cgi.redirect_status_env=0 -d auto_prepend_file=php://input -n 所以有人显然是在尝试一些狡猾的东西,我不太明白,因为我正在运行python,而不是php应用程序。 我很想知道这里发生了什么。 如果我尝试在我的某个部署上进行testing,如下所示: curl -X POST http://my.site.example.com//%63%67%69%2D%62%69%6E/%70%68%70?%2D%64+%61%6C%6C%6F%77%5F%75%72%6C%5F%69%6E%63%6C%75%64%65%3D%6F%6E+%2D%64+%73%61%66%65%5F%6D%6F%64%65%3D%6F%66%66+%2D%64+%73%75%68%6F%73%69%6E%2E%73%69%6D%75%6C%61%74%69%6F%6E%3D%6F%6E+%64%69%73%61%62%6C%65%5F%66%75%6E%63%74%69%6F%6E%73%3D%22%22+%2D%64+%6F%70%65%6E%5F%62%61%73%65%64%69%72%3D%6E%6F%6E%65+%2D%64+%61%75%74%6F%5F%70%72%65%70%65%6E%64%5F%66%69%6C%65%3D%70%68%70%3A%2F%2F%69%6E%70%75%74+%2D%64+%63%67%69%2E%66%6F%72%63%65%5F%72%65%64%69%72%65%63%74%3D%30+%2D%64+%63%67%69%2E%72%65%64%69%72%65%63%74%5F%73%74%61%74%75%73%5F%65%6E%76%3D%30+%2D%64+%61%75%74%6F%5F%70%72%65%70%65%6E%64%5F%66%69%6C%65%3D%70%68%70%3A%2F%2F%69%6E%70%75%74+%2D%6E 我得到: The resource could not […]

我需要使用arg键来重写nginx的匹配位置

我使用一个url用于不同的目的: / path / items:返回一个项目列表 / path / items?id = XXX:redirect到URL / path / items / item?id = XXX 编辑:添加基于Tero的input的解决scheme 我在我的nginx conf文件中试过这个规则: location ~ / { rewrite '^/path/items\?id=([0-9]*)$' /items/item?id=$1? break; } 当我访问页面/path/项目?id = XXX,我得到以下日志: 2016/08/25 14:08:53 [notice] 22903#0: 1“^ / path / items \?id =([0-9] )$”不匹配“/ path / items”,客户端:XXX ,server:local.xxx.ins,请求:“GET / path / items?id = […]

CSP nginx随机数

我在将CSP添加到我的网站时遇到了一些问题。 我在我的nginxconfiguration中configuration了Content-Security-Policy-Report-Only。 我得到这个。 adsbygoogle.js:37 [仅限报告]拒绝应用内联样式,因为它违反了以下内容安全策略指令:“style-src http://example.com ”。 内联执行需要'unsafe-inline'关键字,一个散列('sha256-c + dT7QO / wB / DJJUeioTL / YNq09s5o1WF1vk5RjJU / 4I =')或一个随机数('nonce -…')。 (匿名函数)@ adsbygoogle.js:37 我search了解决scheme。 但是到处都是这样的:“打开”不安全的内联“”。 但其不安全的方法。 我想我可以使用“nonce-”。 但是我不知道如何在nginx conf中实现它。 你可以帮我吗?

nginx auth_basic用于指定端口的地址

我有一个端口3000上运行的服务。我成功地使用下面的nginx指令指向一个URL的地址: server { listen 80; server_name notes.mydomain.foo; location / { proxy_pass http://localhost:3000; } auth_basic "Get lost!"; auth_basic_user_file /etc/nginx/.htpasswd; } 也就是说,当有人去http://notes.mydomain.foo/时 ,nginx成功完成了将请求反向代理到xxx.xxx.xxx.xxx:3000的工作,并向用户展示了一个基本的HTTPauthentication请求。 但是,如果我将浏览器直接指向xxx.xxx.xxx.xxx:3000,auth_basic将被绕过,任何人都可以访问应该限制的内容。 如何在public URL和ip:port地址上启用auth_basic?

无法通过wss连接到服务器

我将下面的nginx.conf文件设置为处理http和https。 我目前正在使用自签名证书来testingssl。 server { listen 80; listen 443 ssl; server_name localhost; ssl_certificate /etc/nginx/ssl/nginx.crt; ssl_certificate_key /etc/nginx/ssl/nginx.key; location / { proxy_pass http://node:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /socketcluster/ { proxy_pass http://node:8000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; } 当我尝试通过本地连接。 http,https&ws://似乎工作正常。 但是,当客户端尝试通过wss://连接时。 我得到下面的错误 WebSocket connection to 'wss://localhost:80/socketcluster/' […]

如何使用nginx代理需要NTLM身份validation的主机?

基本上与如何使用nginx代理需要validation的主机相同的问题? 但是这次使用NTLM身份validation。 不幸的是,公司IIS不接受基本authentication。 我需要configurationnginx为所有代理请求使用一个用户域帐户。 因此,客户端不应该收到任何证书提示。

默认使用Nginx强制对应用程序服务器发出请求

Noobie问题在这里。 我已经在我的Ubuntu中设置了Parse-Server,我现在正在处理一个问题。 我的SSL来自letsencrypt 在这个文件中 /etc/nginx/sites-enabled/default 我有以下 # HTTP – redirect all requests to HTTPS server { listen 80; listen [::]:80 default_server ipv6only=on; server_name example.com; return 301 https://$host$request_uri; } # HTTPS – serve HTML from /usr/share/nginx/html, proxy requests to /parse/ # through to Parse Server server { listen 443; server_name example.com; root /usr/share/nginx/html; index index.html index.htm; […]

nginx根据url slug重写到同一域下的另一台服务器

让我们假设在domain.com下有现有的web应用程序。 这个程序有不同的语言slu </s> domain.com/ln domain.com(默认语言) 我们需要为domain.com部署新的应用程序,其中domain.com/ln必须保持原样(旧应用程序,而不是我们的代码,不同的平台)。 domain.com/ln可能位于一台物理服务器 1上,其中domain.com将位于物理服务器2 (不同的IP)上? 所以我们假设domain.com的DNS被设置为指向server2 。 然后,当请求domain.com/ln请求被发送到server2 ,但可以在那里redirect(通过IP ??)到server1 ,旧的应用程序正在运行? 谢谢

为什么php5-fpm只有在多个wordpress网站处于活动状态时才能执行?

我正在使用一个LEMP堆栈,单独的php5-fpm池用于两个wp页面。 nginx和php5-fpm池configuration文件都是相同的,除了站点和套接字名称。 我做静态池,每个人有两个工人。 观察到的现象如下: 如果我只有一个站点活动,加载<< 1s响应是非常快的。 如果我有两个站点处于活动状态,则第一个站点响应会变为1秒,而第二个站点响应会超过504秒。 如果我不为不同的网站使用不同的游泳池,那么这两个网站的响应速度都会下降到2-10秒。 减速只发生在PHP请求上,静态文件请求不受影响。 当我尝试LAMP堆栈时发生类似的现象。 这里怎么了? 问题在哪里? 我怎么能跟踪这一个? 我无法弄清楚什么logging/debugging/统计选项我有… 🙁 编辑: 这是发展阶段,网站stream量很低,所以这个问题不能说是我用完了。 我有一个请求进来

NGINX完整的URLredirect重写规则需要帮助

我正在尝试redirect到一个完整的URL,包括URL上的每个string。 我要这个 http://www.SITE-A.com/everything?complete=url&fully=redirected redirect到 http://www.SITE-B.com/everything?complete=url&fully=redirected 这工作正常与Apache使用 RewriteRule ^/?$ "http\:\/\/www\.site-b\.com\/" [R=301,L] 我做了一切,我发现在serverfault,但没有运气呢。 我所能得到的总是这个redirect http://www.SITE-A.com/everything?complete=url&fully=redirected redirect到 http://www.SITE-B.com/?complete=url&fully=redirected redirect后,“ 一切 ”都消失了 我试过这些 location /quick-search { try_files $uri http://www.site-b.com/quick-search.php?$arg_q; } 和 location / { rewrite ^/(.*) http://www.site-b.com/$1 permanent; }