Skip to content

Instantly share code, notes, and snippets.

How to log real user’s IP address with Nginx in log files

How to log the real user’s IP instead of the proxy server?

You need use the ngx_http_realip_module module. It is used to change the client address and optional port to the one sent in the specified header fields. Edit your nginx.conf or default.conf file:

$ sudo vi /etc/nginx/conf.d/default.conf

And set the following two directives:

@claudiosanches
claudiosanches / functions.php
Created September 12, 2014 13:49
WooCommerce 2.2 - Register new order statuses.
<?php
// My new order statuses.
function register_my_new_order_statuses() {
register_post_status( 'wc-status-name', array(
'label' => _x( 'Status Name', 'Order status', 'textdomain' ),
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
@mandiwise
mandiwise / Limit Gravity Forms Upload Size
Last active January 16, 2022 14:12
Set a maximum upload size for a Gravity Forms image field
function limit_file_upload_size( $validation_result ) {
$form = $validation_result['form'];
foreach( $form['fields'] as &$field ){
// NOTE: Add a custom CSS class to your image upload field and grab onto it here...
if( strpos( $field['cssClass'], 'choose-file' ) === false )
continue;
@timersys
timersys / readme.txt
Last active August 29, 2015 13:57
Wordpress Social Invitations Readme file
=== Wordpress Social Invitations ===
Author: Damian Logghe
Website: http://www.timersys.com
Contributors: Timersys
Tags: Social Invitations, twitter, facebook, linkedin, hotmail, yahoo
License: http://codecanyon.net/licenses/regular
Stable Tag: 2.4.2
Tested on: 4.0.1
== Description ==
@aufa
aufa / MaxmindGeoIPCountryWhois.sql
Last active May 15, 2020 16:55
Import MAXMIND GEOLITE COUNTRY csv format into mysql .
--
-- this sql structure is for knowledgebase or educational only.
-- please do this on your localhost first before ypu test on your server
--
-- @author : awan
--
-- github : https://github.com/aufa/
--
-- @description this sql is for importing the MaxminD GeoLite Country to mysql data
-- first! we must download the csv format on maxmind developer site :http://dev.maxmind.com/geoip/legacy/geolite/
@dbspringer
dbspringer / some_plugin.php
Created January 28, 2014 01:56
WordPress front-end uploader & current-user only media filter
<?php
class Some_WP_Plugin {
/**
* Init everything here
*/
public function __construct() {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_filter( 'ajax_query_attachments_args', array( $this, 'filter_media' ) );
@BronsonQuick
BronsonQuick / first_name_last_name_gravity_forms.php
Created July 15, 2013 02:01
Change Gravity Forms name labels from "First" and "Last" to "First Name" and "Last Name"
<?php
function sennza_change_first_name( $label, $form_id ){
return "First Name";
}
add_filter( 'gform_name_first', 'sennza_change_first_name', 10, 2 );
function sennza_change_last_name( $label, $form_id ){
return "Last Name";
}
add_filter( 'gform_name_last', 'sennza_change_last_name', 10, 2 );
@malarkey
malarkey / Contract Killer 3.md
Last active April 16, 2024 21:44
The latest version of my ‘killer contract’ for web designers and developers

When times get tough and people get nasty, you’ll need more than a killer smile. You’ll need a killer contract.

Used by 1000s of designers and developers Clarify what’s expected on both sides Helps build great relationships between you and your clients Plain and simple, no legal jargon Customisable to suit your business Used on countless web projects since 2008

…………………………

@nuxlli
nuxlli / sublime_text_2_useful_shortcuts.md
Created September 9, 2011 18:51 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 - Useful Shortcuts

Tested in Mac OS X: super == command

Open/Goto


  • super+t: go to file
  • super+ctrl+p: go to project
  • super+r: go to methods