Fixed Broken Shit
This commit is contained in:
22
user/plugins/reverseproxy/plugin.php
Normal file
22
user/plugins/reverseproxy/plugin.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: ReverseProxy
|
||||
Plugin URI: https://github.com/Diftraku/yourls_cloudflare/
|
||||
Description: Fixes incoming IPs to use the client IP from reverse proxies
|
||||
Version: 2.0
|
||||
Author: Diftraku
|
||||
*/
|
||||
|
||||
// Block direct access to the plugin
|
||||
if( !defined( 'YOURLS_ABSPATH' ) ) die();
|
||||
|
||||
// Add a filter to get_IP for the real IP instead of the reverse proxy
|
||||
yourls_add_filter( 'get_IP', 'reverseproxy_get_ip');
|
||||
function reverseproxy_get_ip( $ip ) {
|
||||
if ( isset( $_SERVER['HTTP_CF_CONNECTING_IP'] ) ) {
|
||||
$ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
|
||||
} elseif ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
}
|
||||
return yourls_sanitize_ip( $ip );
|
||||
}
|
Reference in New Issue
Block a user