1

I've got a virtualbox VM setup as a proxy server between Drupal to try to replicate a CDN causing errors on a client's machine.

My current port is as follows: http://site-name.dd:9999

When I go to the proxy-enabled site, and try to use a given entity reference, I get a 403 error:

An AJAX HTTP error occurred.
HTTP Result Code: 403
Debugging information follows.
Path: http://site-name.dd:8086/index.php?q=entityreference/autocomplete/single/field_guardians/participant/player/NULL
StatusText: Forbidden
ResponseText: 
Access denied | Site Here
Skip to main content
Site Title Here
Main menuName
Another Name
A Third Name
Products
Access denied                                        You are not authorized to access this page.     

My guess is that this is due to me trying to access via port 9999, and the direct site being on 8086.

I believe a similar (though perhaps not exact issue) is also facing the client. How do I deal with this AJAX error? Has anyone seen anything like this?

This is for a D7 site.

EDIT:

I have also tried changing these settings in settings.php:

$conf['reverse_proxy'] = TRUE;

And alternatively setting one of these two and testing with each, with no success:

$conf['reverse_proxy_addresses'] = array('10.1.0.157');

$conf['reverse_proxy_addresses'] = array($_SERVER['REMOTE_ADDR']);

EDIT 2:

From what I can find, the error is because it is getting the original server port from the autocomplete field input element value. So either I need a way for the 8086 port to recognize the 9999 port as legitimate or I need to switch to the 9999 port as correct.

1
  • What happens when you hit the path in the browser? Commented Apr 13, 2017 at 13:24

3 Answers 3

0
+50

Here are some pointers:

  • Set a global $base_url = 'http://example.com:9999' as mentioned by Clemens Tolboom. This should be the easiest.
  • Implement hook_url_outbound_alter and change the options.base_url as per your requirements (for every internal request).
  • Configure the server to work with both the ports? I wonder why are you using 2 ports for the same site though
2

You should set your Base URL to

$base_url="http://site-name.dd:9999";

From default.settings.php

If Drupal is generating incorrect URLs on your site, which could be in HTML headers (links to CSS and JS files) or visible links on pages (such as in menus), uncomment the Base URL statement below (remove the leading hash sign) and fill in the absolute URL to your Drupal installation.

4
  • Is there anyway to make this work without doing this?
    – Jack Ryan
    Commented Apr 11, 2017 at 14:12
  • 1
    This is the easiest way to solve the problem. Why would you want to do it a different way?
    – Felix Eve
    Commented Apr 12, 2017 at 6:46
  • There are not much options left. You could conditional set $base_url on intranet needs or you could use api.drupal.org/api/drupal/modules%21system%21system.api.php/… to code a different strategy which is used by api.drupal.org/api/drupal/includes%21common.inc/function/url/… where the $option['base_url'] marked as internal. Make sure then to use $options['absolute'] = true ... that road will be bumpy. Commented Apr 13, 2017 at 18:12
  • This works when you are using cloudflare. I have an SSL drupal 7 installation sending data to cloudflare. Cloudflare caches the d7 SSL site for me. When I began this, all autocomplete fields stopped working. I also added a rule in cloudflare to not cache the admin pages where my autocomplete fields mostly are (plus node/add* and node/edit*). Excellent answer!
    – Joe Hyde
    Commented May 16, 2018 at 5:13
0

You can set your reverse proxy settings in your web server configuration with the port details. It will work and will not cause any error on autocomplete field.

For apache:

<IfModule mod_proxy.c>  
SSLProxyEngine on
ProxyRequests Off
ProxyPreserveHost On

SSLProxyVerify none 
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
RequestHeader set X-Forwarded-Proto 'https'

ProxyPass "/" "https://base-url/"
ProxyPassReverse "/" "https://base-url/"
ProxyHTMLURLMap "https://base-url/" "/"

<Location />
    ProxyPassReverse /
    ProxyHTMLEnable On
    ProxyHTMLURLMap / /
    RequestHeader unset Accept-Encoding
</Location> 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.