diff --git a/README.txt b/README.txt
index 851c541..ed8f132 100644
--- a/README.txt
+++ b/README.txt
@@ -27,7 +27,17 @@ with one like this:
 
     if (!strpos($_SERVER['QUERY_STRING'], 'imagecache') && !strpos($_SERVER['QUERY_STRING'], '/advagg_')) {
 
-This will most likely be in your settings.php file. If you are still having
+This will most likely be in your settings.php file.
+
+If using Nginx make sure there is a rule similar to this in your configuration.
+http://drupal.org/node/1116618#comment-4321724
+
+If this is still an issue you can try setting the
+"IP Address to send all asynchronous requests to" setting on the
+admin/settings/advagg/config page to -1. This will use the hostname instead of
+an IP address when making the http request.
+
+If you are still having
 problems, open an issue on the advagg issue queue:
 http://drupal.org/project/issues/advagg
 
diff --git a/advagg.admin.inc b/advagg.admin.inc
index 06f6714..6812bfc 100644
--- a/advagg.admin.inc
+++ b/advagg.admin.inc
@@ -218,7 +218,7 @@ function advagg_admin_settings_form() {
     '#type'           => 'textfield',
     '#title'          => t('IP Address to send all asynchronous requests to'),
     '#default_value'  => variable_get('advagg_server_addr', FALSE),
-    '#description'    => t('If left blank it will use the same server as the request.'),
+    '#description'    => t('If left blank it will use the same server as the request. If set to -1 it will use the host name instead of an IP address.'),
   );
 //   $form['advagg_debug'] = array(
 //     '#type'           => 'checkbox',
@@ -338,7 +338,7 @@ function advagg_admin_settings_form_validate($form, &$form_state) {
   }
 
   // If the IP field is not blank, check that its a valid address.
-  if (!empty($form_state['values']['advagg_server_addr']) && ip2long($form_state['values']['advagg_server_addr']) === FALSE) {
+  if (!empty($form_state['values']['advagg_server_addr']) && $form_state['values']['advagg_server_addr'] != -1 && ip2long($form_state['values']['advagg_server_addr']) === FALSE) {
     form_set_error('advagg_server_addr', t('Must be a valid IP address.'));
   }
 
diff --git a/advagg.install b/advagg.install
index 8de3e5f..ebda908 100644
--- a/advagg.install
+++ b/advagg.install
@@ -55,14 +55,14 @@ function advagg_uninstall() {
   drupal_uninstall_schema('advagg');
 
   // Remove variables.
-  variable_del('advagg_enabled');
-  variable_del('advagg_stale_file_threshold');
   variable_del('advagg_stale_file_last_used_threshold');
   variable_del('advagg_file_last_used_interval');
+  variable_del('advagg_stale_file_threshold');
   variable_del('advagg_gzip_compression');
   variable_del('advagg_async_generation');
   variable_del('advagg_socket_timeout');
   variable_del('advagg_server_addr');
+  variable_del('advagg_enabled');
   variable_del('advagg_debug');
 
   // Remove files.
@@ -256,10 +256,13 @@ function advagg_check_missing_handler() {
 
   // Setup request
   list($css_path, $js_path) = advagg_get_root_files_dir();
-  $ip = variable_get('advagg_server_addr', FALSE);
-  if (empty($ip)) {
-    $ip = empty($_SERVER['SERVER_ADDR']) ? '127.0.0.1' : $_SERVER['SERVER_ADDR'];
-  }
+    $ip = variable_get('advagg_server_addr', FALSE);
+    if ($ip == -1) {
+      $ip = $_SERVER['HTTP_HOST'];
+    }
+    elseif (empty($ip)) {
+      $ip = empty($_SERVER['SERVER_ADDR']) ? '127.0.0.1' : $_SERVER['SERVER_ADDR'];
+    }
   $filepath = $css_path . '/css_missing' . mt_rand() . time() . '_0.css';
   $url = 'http://' . $ip . $base_path . $filepath;
   $headers = array(
diff --git a/advagg.module b/advagg.module
index 8846f4c..1bd05e1 100644
--- a/advagg.module
+++ b/advagg.module
@@ -1810,7 +1810,10 @@ function advagg_css_js_file_builder($type, $files, $counter = '', $force = FALSE
       if (variable_get('advagg_async_generation', ADVAGG_ASYNC_GENERATION)) {
         // Request file.
         $ip = variable_get('advagg_server_addr', FALSE);
-        if (empty($ip)) {
+        if ($ip == -1) {
+          $ip = $_SERVER['HTTP_HOST'];
+        }
+        elseif (empty($ip)) {
           $ip = empty($_SERVER['SERVER_ADDR']) ? '127.0.0.1' : $_SERVER['SERVER_ADDR'];
         }
         $url = 'http://' . $ip . $base_path . $filepath . '?generator=1';
diff --git a/advagg_js_compress/advagg_js_compress.module b/advagg_js_compress/advagg_js_compress.module
index f33eadd..12edd18 100644
--- a/advagg_js_compress/advagg_js_compress.module
+++ b/advagg_js_compress/advagg_js_compress.module
@@ -221,7 +221,10 @@ function advagg_js_compress_test_compression($files_to_test) {
     $query['key'] = $key;
     $query_string = http_build_query($query, '', '&');
     $ip = variable_get('advagg_server_addr', FALSE);
-    if (empty($ip)) {
+    if ($ip == -1) {
+      $ip = $_SERVER['HTTP_HOST'];
+    }
+    elseif (empty($ip)) {
       $ip = empty($_SERVER['SERVER_ADDR']) ? '127.0.0.1' : $_SERVER['SERVER_ADDR'];
     }
     $url = 'http://' . $ip . $base_path . 'advagg/js_compress_test_file';
