Nginx多场景挂载维护页面

需求1:访问网站的任何页面,都跳转到同一个页面,而这一个页面就是维护页面。(外部用户和公司内部的人都跳转到维护页面)

server {
    listen ;
    index index.html index.htm;
 
    server_name www.example.com;
 
    if ($request_uri !~ "^/maintain.html$") {
        rewrite ^(.*) http://www.example.com/maintain.html permanent;
    }
 
    location / {
        ...
    }
}
server {
    listen 80 backlog=1023;
    server_name www.xxx.com;
    set $MAGE_ROOT /var/www/html;

    set $my_http "https";
    set $my_ssl "on";
    set $my_port "443";

    access_log /var/log/nginx/magento_access.log format buffer=64k flush=1m;
    error_log /var/log/nginx/magento_error.log;
    
    root $MAGE_ROOT/pub;

    rewrite .* /errors/maintain.html;

需求2:

(1) 不能关闭所有页面的访问,对于某些重要页面还是得开放给外部用户,比如充值页面等。

(2) 对于新上线的功能,我们只是不希望外部访问到,但是我们公司内部得能访问,这样就能进行测试,测试完后再对外开放。

server {
    listen ;
 
    server_name www.example.com;
 
    set $flag 0;
 
    if ($remote_addr !~ "192.168.198.2") {
        set $flag "${flag}1";
    }
 
    if ($request_uri !~* ^(/maintain.html|/pay/index.html)$) {
        set $flag "${flag}2";
    }
 
    if ($flag = "012") {
        rewrite ^(.*) http://192.168.198.131/maintain.html permanent;
    }
 
    location / {
        ...
    }
}
server {
    listen 80;
    root /xxx/xxx/src;
    index index.html index.htm;

    server_name test.xxx.com;

    set $flag 0;
      if ($request_uri !~ "(/static/.*)$"){
          set $flag "${flag}1";
      }
      if ($request_uri !~ "/502.html$" ){
          set $flag "${flag}2";
      }
      if ($flag = "012") {
         rewrite ^(.*) http://test.xxx.com/502.html permanent;
      }

 location /{
     ...

对于公司内部(192.168.198.2)来说,我们可以访问一切位置。

对于外部人员来说,如果我们访问的页面不是/maintain.html或者/pay/index.html时,那么会强制跳转到/maintain.html页面。

等同于说,对外部人员开放的只有/maintain.html和/pay/index.html页面,其他业务无权访问。

这样就实现了需求。

备注:我在测试时,始终没有绕过弯,一直卡在对于外网地址,分为跳转和不跳转,结果一直没写出来。其实应该换一个思维,那就是哪些对外开放,哪些对外不开放。

开放的只有/maintain.html和/pay/index.html,其他都不开放。

需求3::当用户访问我们的网站,出现502状态码时,nginx自动跳到个性化页面,而不是显示冰冷的502数字。

server {
     listen ;
     server_name www.example.com;
 
     # ... 省略掉 N 行代码
 
     error_page  = @tempdown;
 
     location @tempdown {
         rewrite ^(.*)$ /custom.html break;
     }
}

CP:https://www.bbsmax.com/A/8Bz83gxydx/

Exchange Online Enable SMTP AUTH

第一步,https://docs.microsoft.com/en-us/powershell/exchange/exchange-online-powershell-v2?view=exchange-ps,安装 EXO V2 mode

第二步:Set-ExecutionPolicy RemoteSigned

第三步:Install-Module -Name ExchangeOnlineManagement (https://docs.microsoft.com/en-us/powershell/exchange/connect-to-exchange-online-powershell?view=exchange-ps)

第四步:Import-Module ExchangeOnlineManagement

第五步:Connect-ExchangeOnline -UserPrincipalName howard.wen@heinetworx.com

第六步:Set-TransportConfig -SmtpClientAuthenticationDisabled $false (https://docs.microsoft.com/en-us/powershell/exchange/connect-to-exchange-online-powershell?view=exchange-ps