Referer ÎÞ·¨»á¼ûlaravel
ÔÚweb¿ª·¢ÖУ¬¾³£»áÓöµ½referer£¨Òý¼öÕߣ©µÄÎÊÌ⣬ÆäÖÐ×î³£¼ûµÄÇéÐξÍÊÇrefererÎÞ·¨»á¼ûlaravel¡£laravel×÷Ϊһ¿îÊ¢ÐеÄphp¿ò¼Ü£¬Ê¹ÓÃÆձ飬ѧϰºÍʹÓÃÄÑÌâ¶ÈÏà¶Ô½ÏС£¬È»¶ø£¬ÔÚʹÓÃÖÐÒ²»áÓöµ½Ò»Ð©ÎÊÌ⣬ÆäÖоͰüÀ¨refererÎÊÌâ¡£ÄÇô£¬ÎªÊ²Ã´»á·ºÆðrefererÎÊÌ⣬ÔÚlaravel¿ò¼ÜÖÐÔõÑù½â¾öÄØ£¿±¾ÎĽ«Îª¸÷È˾ÙÐÐÏêϸÆÊÎö¡£
ʲôÊÇRefererÎÊÌâ
Ê×ÏÈ£¬ÎÒÃÇÐèÒªÃ÷È·Ò»ÏÂʲôÊÇRefererÎÊÌâ¡£RefererÌåÏÖÇëÇóȪԴ£¬ÊÇÒ»¸öHTTPÍ·²¿ÐÅÏ¢×ֶΣ¬ÔÚWeb¿ª·¢ÖÐÓÐ×ÅÖ÷ÒªµÄ×÷Ó㬿ÉÒÔÓÃÀ´»ñÈ¡¿Í»§¶ËµÄÍøÒ³»á¼ûȪԴµØµã¡£ÀýÈ磬´ÓAÕ¾µãÌøתµ½BÕ¾µãʱ£¬BÕ¾µã¾Í¿ÉÒÔ»ñÈ¡µ½ÇëÇóȪԴµØµãΪAÕ¾µãµÄURL¡£¿ÉÊÇ£¬ÈôÊÇ¿Í»§¶ËµÄReferer±»¸Ä¶¯»òÕß²»±£´æʱ£¬ÄÇô¾Í¿ÉÄÜ·ºÆðRefererÎÊÌâ¡£
ÔÚLaravel¿ò¼ÜÖУ¬ÓÐЩ¹¦Ð§»òÕßAPIÐèÒª¼ì²éRefererµÄÖµ²Å»ªÖ´ÐлòÕß·µ»ØÏìӦЧ¹û¡£ÈôÊÇ·¢Ã÷¿Í»§¶ËµÄReferer²»ÇкÏÒªÇó£¬ÄÇô¾Í¿ÉÄ᷺ܻÆðÎÞ·¨»á¼ûµÄÎÊÌâ¡£
RefererÎÊÌâµÄÔµ¹ÊÔÓÉ
RefererÎÊÌâµÄ·ºÆð£¬ÍùÍùÓëä¯ÀÀÆ÷»òÕßÊðÀíЧÀÍÆ÷Óйء£ÆäÖУ¬×î³£¼ûµÄÇéÐξÍÊÇä¯ÀÀÆ÷ÖÐÆôÓÃÁËÒþ˽±£»¤Ä£Ê½¡£Òþ˽±£»¤Ä£Ê½»áեȡä¯ÀÀÆ÷ÏòЧÀÍÆ÷·¢ËÍReferer£¬Òò´Ë£¬¾Í»áµ¼ÖÂLaravel¿ò¼ÜÔÚijЩÇéÐÎÏÂÎÞ·¨Õý³£»á¼û¡£±ðµÄ£¬Ò»Ð©ä¯ÀÀÆ÷À©Õ¹»òÕß²å¼þÒ²¿ÉÄÜ»áÓ°ÏìRefererµÄת´ï¡£
³ý´ËÖ®Í⣬ÊðÀíЧÀÍÆ÷ºÍCDNÒ²¿ÉÄܻᵼÖÂRefererÎÊÌâ¡£ÔÚʹÓÃÊðÀíЧÀÍÆ÷»òÕßCDNʱ£¬¿Í»§¶Ëä¯ÀÀÆ÷ºÍЧÀÍÆ÷Ö®¼ä¿ÉÄÜ»á¶à´Îת·¢ÇëÇ󣬲î±ðµÄÊðÀíЧÀÍÆ÷ºÍCDNÌṩÉ̶ÔRefererµÄ´¦Àí·½·¨Ò²²»¾¡Ïàͬ£¬Òò´Ë£¬¾Í¿ÉÄÜ·ºÆðRefererÖµ²»×¼È·µÄÇéÐΡ£
½â¾öRefererÎÊÌâµÄ·½·¨
ΪÏàʶ¾öRefererÎÊÌ⣬ÔÚLaravel¿ò¼ÜÖУ¬ÎÒÃÇ¿ÉÒÔ½ÓÄÉÒÔϼ¸ÖÖ·½·¨¡£
£¨1£©¹Ø±ÕÒþ˽±£»¤Ä£Ê½
ÈôÊÇ¿Í»§¶Ëä¯ÀÀÆ÷¿ªÆôÁËÒþ˽±£»¤Ä£Ê½£¬ÄÇô¾ÍÐèÒª½«Æä¹Ø±Õ¡£Ïêϸ²Ù×÷°ì·¨¿ÉÄÜÒòä¯ÀÀÆ÷°æ±¾¶øÒ죬һÑùƽ³£¿ÉÒÔÔÚä¯ÀÀÆ÷µÄÉèÖûòÕßÑ¡ÏîÖоÙÐе÷½â¡£
£¨2£©ÉèÖð×Ãûµ¥
½«Õý³£µÄRefererÌí¼Óµ½°×Ãûµ¥ÖУ¬ÆäËûµÄRefererÔò²»Óè´¦Àí¡£ÔÚLaravel¿ò¼ÜÖУ¬¿ÉÒÔÔÚconfig/trustproxy.phpÎļþÖÐÉèÖÃtrusted_proxiesÊý×飬½«ÐèÒªÉèÖÃΪ°×Ãûµ¥µÄRefererÉèÖÃΪtrusted_proxiesµÄÖµ¼´¿É¡£
£¨3£©ÉèÖÃReferer¼ì²é
ÔÚLaravel¿ò¼ÜÖУ¬¿ÉÒÔͨ¹ýÉèÖÃ$request->headers->set(‘Referer’, $referer)À´ÊÖ¶¯ÉèÖÃReferer¡£Í¨¹ýÕâÖÖ·½·¨£¬¾Í¿ÉÒÔ½«RefererÉèÖÃΪÐèÒªµÄÖµ£¬´Ó¶ø½â¾öReferer¼ì²éµÄÎÊÌâ¡£
£¨4£©Ê¹ÓÃÊðÀíЧÀÍÆ÷
ÈôÊÇÒѾÎÞ·¨Í¨¹ýÆäËû·½·¨½â¾öRefererÎÊÌ⣬ÄÇô¾Í¿ÉÒÔʹÓÃÊðÀíЧÀÍÆ÷¡£ÊðÀíЧÀÍÆ÷¿ÉÒÔ×èµ²ÇëÇ󣬲¢½«ÇëÇóÖеÄRefererÖµÉèÖÃΪ׼ȷµÄÖµ¡£ÏêϸµÄÊðÀíЧÀÍÆ÷ʵÏÖ·½·¨£¬¿ÉÒԲο¼Ò»Ð©Ê¢ÐеÄÊðÀíЧÀÍÆ÷ÈçNginx»òÕßApacheµÄÉèÖÃÒªÁì¡£
½áÓï
RefererÎÊÌâÔÚWeb¿ª·¢ÖÐÊÇÒ»¸ö³£¼ûµÄÎÊÌâ¡£ËäÈ»ÔÚLaravel¿ò¼ÜÖУ¬½ÓÄÉÁËһЩĬÈϵļì²é»úÖÆ£¬¿ÉÊÇ£¬ÓÐʱ¼äÕÕ¾ÉÐèÒªÎÒÃǾÙÐÐÌØÁíÍâÉèÖ㬴Ӷø½â¾öRefererÎÊÌâ¡£¹ØÓÚ¼ÓÈëLaravel¿ª·¢µÄ¿ª·¢Õ߶øÑÔ£¬Ã÷È·RefererÎÊÌâµÄÔµ¹ÊÔÓÉ£¬ÒÔ¼°ÊìϤÏà¹ØµÄ½â¾öÕ½ÂÔ£¬ÊǺÜÊÇÖ÷ÒªµÄ¡£Ï£Íû±¾ÎÄÄܹ»¶Ô¸÷ÈËÔÚѧϰºÍʹÓÃLaravel¿ò¼ÜʱÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊÇReferer ÎÞ·¨»á¼ûlaravelµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡