在Nginx配置文件中使用Web服务

时间:2015-08-19 15:48:30

标签: c++ c linux nginx

请参阅此配置

location ~* ^/dl/([a-zA-Z0-9\-\_]+)/([0-9]+)(.*)$ {
root /home/GodOFWar/public_html/;
secure_link $1,$2;
secure_link_md5 oH4fJ4KiON6sRT5tXDC1$3$2;
if ($secure_link = "") {
return 403;
}
if ($secure_link = "0") {
return 403;
}
rewrite ^/dl/([a-zA-Z0-9\-\_]+)/([0-9]+)/(.*)$ /$3 break;
}

在检查令牌和到期时间之后(在重写之前),我想调用一个模块,其操作是将令牌和用户IP发送到Web服务;如果Web服务的输出为True,则下载文件,如果为False,则接收用户名/密码并将其发送到Web服务,如Http Auth Basic中所示。 如果Web服务的输出为True,则下载文件,如果为False,则给出错误404

例如:

http://www.example.com/dl/GghBgdpQluCkx17nbBY29w/1440849227/user/John/Files/Video.Mp4

/*
  * After the token and expiry time are checked
  * Token And user IP are Sent to the web service :
  * WS : http://www.example.com/checkToken/GghBgdpQluCkx17nbBY29w/52.152.62.145
*/
if(True) {
  rewrite ^/dl/([a-zA-Z0-9\-\_]+)/([0-9]+)/(.*)$ /$3 break;
}
else {
    /*
     * a Username/password is received and sent to the web service   similar Http Auth          
      Module.
     * WS : http://www.example.com/checkUser/GodOfWar/123456
    */
    if(True) {
      rewrite ^/dl/([a-zA-Z0-9\-\_]+)/([0-9]+)/(.*)$ /$3 break;
    }
    else {
        return 404;
    }
}

请帮我解决问题

0 个答案:

没有答案