Articles of nginx

在nginx中使用别名服务静态文件

我已经在nginx中指定了以下位置: location ~ ^/blah/(.*)$ { alias /html/$1; autoindex on; allow all; } html目录具有以下结构: /html/ – other/ – test2.htm – test.htm 我可以浏览到http://server/blah并获取文件列表。 我可以服务http://server/blah/other/test2.htm 。 当我尝试访问http://server/blah/test.htm我得到一个301,并redirect到http://server/blah/test.htm/ ,然后是404。 我怎样才能在http://server/blah/test.htm ?

404错误在nginx中设置子目录

我将一个子目录/博客添加到我的服务器上,这是一个WordPress的安装。 我已经在nginx上设置了以下configuration,但在/博客上发生了404错误。 网站/configuration的其余部分是完美的。 我错过了什么? domain.com server { listen 80; listen [::]:80; server_name domain.com; return 301 https://domain.com$request_uri; } server { listen 443 ssl; server_name domain.com; ssl_certificate /etc/ssl/domain_com-bundle.crt; ssl_certificate_key /etc/ssl/domain_com.key; root /opt/domain.com/public/; location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location /blog { root /var/www/html/siteWordpress/; index […]

nginx位置排除一个特定的请求

在WordPresspipe理员,我有nginx的基本http身份validation通过使用这里面的nginxconfiguration: location ^~ /wp-login.php { auth_basic "Restricted Area: WordPress"; auth_basic_user_file /etc/nginx/wp.htpasswd; include /etc/nginx/fastcgi.conf; fastcgi_pass unix:/var/run/php5-fpm.sock; } 现在这个工作,但我需要添加一个排除它为wp-login.php?action=postpass 我从这篇文章中学到了nginx如何select使用哪个位置块来提供特定的请求。 ^~被用来覆盖我们可能有的任何规则,我想我需要指定一个正则expression式规则和一个确切的规则,它应该做所需的工作。 这对我来说是最有意义的,但它不起作用: location = /wp-login.php?action=postpass { include /etc/nginx/fastcgi.conf; fastcgi_pass unix:/var/run/php5-fpm.sock; } location ~* /wp-login.php { auth_basic "Restricted Area: WordPress"; auth_basic_user_file /etc/nginx/wp.htpasswd; include /etc/nginx/fastcgi.conf; fastcgi_pass unix:/var/run/php5-fpm.sock; } 另外,尝试其他随机组合,但没有运气。 值得一提的是,当请求url不是wp-login.php或者URL中的任何东西,除了?action=postpass 请指教! 提前致谢!

nginx + php 7 + $ _GET params + Homestead

我的.htaccess是: # nginx configuration location / { if (!-e $request_filename){ rewrite ^(.+)$ /index.php?url=$1 break; } } 我有像这样configurationnginx: server { listen 80; listen 443 ssl http2; server_name prueba_nginx.net; root "/home/vagrant/Code/prueba_nginx/public"; index index.html index.htm index.php; charset utf-8; location / { try_files $uri $uri/ /index.php?$query_string; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt […]

如何代理Nginx背后的SaltStack

默认情况下,Saltstack在安装时使用端口4505和4506来连接Minions。 但是我无法打开Salt主服务器上的端口4505和4506。 有没有什么办法可以configurationNginx背后的Salt master,并且有通过Nginx连接master的爪牙。 非常感谢。

nginx反向代理不能访问某些网站

我已经安装了nginx作为我的专用networking中的反向代理。 一切工作正常,除了一些网站,如: www.dhl.com(在控制台中找不到错误404) www.bbc.com(它将保持循环)。 conf是如下: server { server_name ~^(www\.)?(?<domain>.+)$; access_log /var/log/nginx/proxy.access.log main; error_log /var/log/nginx/proxy.error.log crit; listen 192.168.98.254:8081; resolver 8.8.8.8; location / { proxy_set_header Accept-Encoding ""; proxy_pass http://$domain; proxy_redirect off; proxy_set_header Host $host; # Optional headers proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } 请任何机构知道如何解决这种types的网站? 谢谢, Areeb

访问被拒绝WordPress的pipe理面板(Nginx / Ubuntu的)

设置: nginx / 1.4.6,Ubuntu / 14.04.3 LTS,Wordpress / 4.5.4 我从一个子目录运行Wordpress(在本文后面: 使用预先存在的子目录安装 ),我发现使网站工作的唯一方法是将此作为我的nginxconfiguration的一部分: location / { try_files $uri /wordpress$uri/ /wordpress/index.php?$args; } …但有了它,我无法访问pipe理面板 。 与其他nginxconfiguration我看到的HTML内容,但我得到了404的每个外部资产(CSS,图像,JS等)。 我尝试了许多不同的configuration,没有任何结果在这个职位(等等)之后: Nginxconfiguration – 我无法访问WordPresspipe理区域 Nginx的 – 在一个子目录中的wordpress,应该传递什么数据? 当前的nginxconfiguration: server { listen 80; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html; index index.php; server_name mysite.com; location / { #try_files $uri $uri/ /index.php?$args; #try_files $uri /wordpress$uri/ […]

Nginx:利用浏览器caching远程资源(图片)

在我的一个站点有一些图像被托pipe到远程服务器。 我还没有想出如何将Cache-Control设置为远程源。 对于我正在使用的本地文件: location ~* \.(jpg|jpe?g|gif|png|ico|cur|gz|svgz|mp4|ogg|ogv|webm|htc|css|js|otf|eot|svg|ttf|woff|woff2)(\?ver=[0-9.]+)?$ { expires 1M; add_header Access-Control-Allow-Origin '*'; add_header Pragma public; add_header Cache-Control "public, must-revalidate, proxy-revalidate"; access_log off; } 哪个工作很好。 我试图添加一个位置块,其中包含文件的远程位置与本地文件相同的原则,例如https://example.com/img/,但nginx没有做任何事情。 这一切的目的是为了提高网站速度。 任何build议将不胜感激。

如何使用NGINX发送邮件

我在我的networking服务器上使用NGinx。 是否有可能通过NGinx服务器发送电子邮件,没有一个帐户(Gmail,微软,…),并没有在服务器上的专用SMTP服务器? 我的域名的邮件stream量由其他服务器处理。 我只是想从服务器发送邮件(信息,警告,quotalimits,…)给一些人。 谢谢!

浏览器仍然看到/使用旧的NGINX SSL证书

我刚刚获得了一个新的SSL证书,这个证书以前被通配符SSL证书所覆​​盖。 它已经安装了一个多星期,大约有99%的用户没有问题。 现在只有一个或两个(我知道)得到一个“网站不受信任”的警告,所以我假设他们在连接时看到旧的证书。 有没有办法强制所有的浏览器使用新的SSL证书时,他们连接? (它在Ubuntu上是一个NGINX)