Articles of nginx

nginx,否认所有其他子域和IP地址

我有这个nginxconfiguration。 我想让nginx拒绝除secure.myserver.com之外的所有子域,但是这个configuration会拒绝所有的东西,包括secure.myserver.com 如果我删除拒绝块,那么我的主块工作正常。 #main server { listen 443 ssl; listen [::]:443 ssl; server_name secure.myserver.com; } #deny server { listen 443 default_server; server_name _; deny all; }

Nginx的鳄梨酱,但没有工作与代理的外部局域网

我在Ubuntu 16.04上使用Nginx将Guacamole作为RDP无客户端使用。这在我的计算机上完美地工作在外部局域网中。 但不能在另一个阻塞端口的外部局域网中工作。 只有端口80和443可以使用。 当我从我的浏览器去应用程序: http:// myserverguaca / guacamole我可以看到login页面并login。 但是,当我尝试启动RDP有一个加载,然后一条消息,说“服务器花了很多时间来回应” 你认为我必须转发另一个端口吗? 因为我已经将端口8080转发到80,RDP使用:3389,但是这是在本地主机,不知道为什么我也应该转发这一点。 我希望你能帮助我。 有我的RDP访问configuration(user-mapping.xml) <user-mapping> <connection name="rdp"> <protocol>rdp</protocol> <param name="hostname">localhost</param> <param name="port">3389</param> <param name="server-layout">fr-fr-azerty</param> <param name="ignore-cert">true</param> </connection> </user-mapping> 和我的configurationnginx(网站启用/鳄梨)` server { listen 80; server_name vpsmyserver.net.com; location /guacamole/ { proxy_pass http://localhost:8080/guacamole/; proxy_buffering off; proxy_http_version 1.1; proxy_set_header X_Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; access_log off; […]

无法连接到某些ISP上的网站(太多redirect)

我突然有一个奇怪的问题,我敢肯定,我已经取消了应用程序的罪魁祸首,但我本质上不是服务器pipe理员,所以我可能是错的。 https://launchwestco.com 的Linode Ubuntu 14.04.4 LTS Nginx 1.10.1 Laravel 5.2 从我的家,办公室和其他networking加载罚款。 在Verizon,它不是加载,给错误太多的redirect。 当我的手机或我的笔记本电脑上加载我的手机时,这是真实的。 问题似乎在昨天晚上出现,至less在我们注意到的时候。 我怀疑这是在服务器configuration的东西,但我的Nginxconfiguration似乎是正确的: server { listen 80; listen [::]:80 ipv6only=off; server_name launchwestco.com *.launchwestco.com; rewrite ^ https://$host$request_uri? permanent; } server { listen 443 ssl; listen [::]:443 ssl ipv6only=off; server_name launchwestco.com *.launchwestco.com; root /home/forge/envoyer/com.launchwestco/current/public; client_max_body_size 55M; underscores_in_headers on; # FORGE SSL (DO NOT REMOVE!) ssl_certificate […]

Nginx作为GeoIP Global LoadBalancer和实际距离应用服务器的距离

我的客户正在使用Magento的电子商务全球解决scheme。 主要国家是美国/欧盟/中国。 目前在意大利只有1个VM,为所有的stream量提供服务。 我想在AWS或Google Cloud上创build3个虚拟机,每个虚拟机一个,在这个阶段不重要。 缅因州DNS 1.2.3.4应指向一个www.mydomain.it,其中1.2.3.4它是一个nginx虚拟机(在欧洲数据中心)configuration了MaxMind GeoIP模块。 这beciture网站有多个语言和多个目录/价格/数量为每个国家和nginx我可以通过必要的标题和variables到Magento所以中小企业知道很多语言向不同国家的客户展示。 我的问题是:当stream量会碰到nginx虚拟机,它会proxy_pass到美国的服务器,美国的服务器会真的服务于美国的stream量,或者美国的stream量将总是通过nginx虚拟机stream动,所以它会滞后和放缓? 我的目标是将stream量转发到基于访问者国家的对应虚拟机,所以这个虚拟机将服务于stream量而不是nginx虚拟机

阻止网站访问不通过预定的域名

我有一个在Debian上有多个域的nginx服务器。 他们都住在html文件夹中。 然后Alogging指向我的服务器,您可以通过访问https://mywebsite.biz访问/var/www/html/mywebsite.biz的文件。 我也使用Let's Encrypt分配他们的TLS证书。 它看起来像这样: └── html ├── mywebsite.biz ├── anotherwebsite.net ├── example-three.com └── somewebsite.ca 但是,您可以通过我的IP地址访问该html文件夹而无需TLS,如下所示: http://216.58.216.78/mywebsite.biz 但是我也有这样的情况,我希望这样的事情发生。 例如,如果我想设置一个testing站点,然后才能将该域指向我的服务器。 为此,我使用noip.com为其分配一个友好名称,如下所示: http://myservername.ddns.net/somewebsite.ca (只是一个testing网站) 只有一些网站通过IP地址/友好名称拒绝访问的最佳方式是什么? 拒绝/redirect这些: http://myservername.ddns.net/mywebsite.biz http://216.58.216.78/mywebsite.biz 允许这个: http://myservername.ddns.net/somewebsite.ca 我的猜测是在那里redirect它们,但是我对nginx有点新,并且想确保这是最好的方法。

configurationnginx为反向代理http uri – >私人个人服务器

我有一个服务器,没有域设置。 我通过端口80上的IP访问它。我有IIS上的端口8080,8081,8082三个网站。我只想当有人进入SERVER_IP / foo1,nginx显示内容从192.168.1.100:8080 SERVER_IP / foo2 – > 192.168.1.100:8081 SERVER_IP / foo3 – > 192.168.1.100:8082 这些私人服务器是复杂的Web应用程序,并具有身份validation,其他网页等我感谢任何帮助。 我目前的configuration是放 location /foo1/ { if ($request_uri ~* "/foo1/(.*)") { proxy_pass http://192.168.1.100:8080/$1; } 在nginx的默认服务器块中,显然这是行不通的。

在Serverpilot上configuration301redirect强制https:// no-www的最佳方式(nginx / apache服务器)

现在的情况: 我成功地设法在我的Serverpilot(nginx / apache)服务器上手动设置SSL证书。 因为我的网站在Serverpilot服务器上运行,所以部分是nginx,部分是Apache。 我可以在我的服务器上执行Apache中的所有redirect,但我更喜欢在我的nginxconfiguration文件中以正确的方式执行,因为我已经读过这种方法。 由于nginx由serverpilotpipe理,所以我必须在位于我的服务器上的这个文件夹中的一个单独的nginxconfiguration文件中进行更改:/etc/nginx-sp/vhosts.d。 如您所见,Serverpilot不使用标准nginxconfiguration,Serverpilot安装来自Serverpilotconfiguration文件。 这个/etc/nginx-sp/vhosts.d文件夹中有两个文件: example.conf(这是Serverpilot的标准configuration文件,我没有改变它) example.ssl.conf(这是我用ssl规则创build的文件) 据我所知,Nginx首先读取第一个.conf文件,然后读取第二个.conf文件。 那是对的吗? 什么 example.conf(Serverpilot标准configuration文件)包含以下内容: server { listen 80; listen [::]:80; server_name server-example example.net www.example.net ; root /srv/users/serverpilot/apps/example/public; access_log /srv/users/serverpilot/log/example/example_nginx.access.log main; error_log /srv/users/serverpilot/log/example/example_nginx.error.log; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; include /etc/nginx-sp/vhosts.d/example.d/*.nonssl_conf; include /etc/nginx-sp/vhosts.d/example.d/*.conf; } 我创build了一个包含以下内容的example.ssl.conf: server { listen 443 ssl http2; listen […]

除非url参数存在,否则Nginx否认503的URL

我目前限制一个WordPress文件wp-login.php只有我的IP地址 – 但我想允许访问该页面,如果给定的URL参数存在。 所以基本上这是我所尝试的 location ~ ^/(wp-admin|wp-login\.php) { if ($arg_action = "true") { break; } allow xx.xxx.xxx.xxx; deny all; // fastcgi_params } 所以在这个代码片段中,如果用户访问wp-login.php?action = true,页面应该显示。 但是,如果用户访问wp-login.php,他们应该被拒绝。 这个代码不起作用,任何提示将不胜感激。

有没有一个“快速”的方法来确定网站被敲打?

我有一些在给定的Ubuntu服务器上运行多个低stream量网站的客户端。 当我设置这些东西时,我总是configuration每个Nginx虚拟主机写入自己的访问错误日志文件。 这种方法对于几乎所有的事情都很有效,但是时不时的一个场景就是当一个站点受到某种暴力攻击,甚至怪异的非恶意事件的攻击时,却会产生类似的不必要的有害的stream量。 我可以看到CPU和内存的高峰,但我不知道该怎么做的是快速确定哪个站点正在被攻击。 通常我发现自己在每个站点访问日志上运行tail -f几秒钟,直到我发现正在写入的日志比预期更频繁。 我想知道是否有某种单线程的脚本,可以帮助我快速识别哪些访问日志文件增长最快或写入最多或其他。 任何事情都会让我更加接近确定目标的速度,比我目前以我的辛苦方法达到目标的速度更快。

Nginx代理通过X-Accel的方法改变为GET

我已经在开发中运行一个Nginx的X-Accel代理服务器,具有以下configuration: upstream gate_proxy { server 127.0.0.1:8889; } server { listen 80 default_server; server_name default; charset utf-8; client_max_body_size 75M; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; # Send all traffic to gate first location / { proxy_pass_header Server; proxy_set_header Host $http_host; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Scheme $scheme; proxy_pass http://gate_proxy; } # Proxy to Apache […]