Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Posting comment causes new page to be loaded with referer to a LAN IP

edited June 2011 in Vanilla 2.0 - 2.8
Consider:

http://EXAMPLE.COM/MYFORUM/index.php?p=/discussion/12/test-thread

Posting on that thread leads the browser to reload a link like:

http://INTERNAL-IP-ADDRESS/MYFORUM/index.php?p=/discussion/comment/39#Comment_39

This will lead to failure in viewing the new post unless we're on the local network and having the browser bypassing the local proxy for local addresses.
However, the post is actually registered, and if I swap the INTERNAL-IP-ADDRESS with my EXAMPLE.COM the comment is actually there.

So the problem here seems something like a post-posting issue of which-page-shall-I-(the-forum)-display as the refresh page?


So is there a way to make the forum ALWAYS ignore the host machine internal address and instead always use the domain one provided by the gateway machine when it constructs its request links?

Tagged:

Best Answer

  • Options
    ToddTodd Chief Product Officer Vanilla Staff
    edited June 2011 Answer ✓
    The site tries to get your host from the following $_SERVER variables: HTTP_HOST then SERVER_NAME.

    You can try one of the following:

    1. If someone has the ability in your organization to configure your server properly then you're good to go.

    2. Try using your .htaccess file to set the appropriate $_SERVER variable. See this or google around a little bit.

    3. Write a plugin that manually sets the host to the appropriate value:
    public function Base_AfterAnalyzeRequest_Handler($Sender, $Args) {
    Gdn::Request()->RequestHost('EXAMPLE.COM');
    }

Answers

  • Options
    ToddTodd Chief Product Officer Vanilla Staff
    edited June 2011 Answer ✓
    The site tries to get your host from the following $_SERVER variables: HTTP_HOST then SERVER_NAME.

    You can try one of the following:

    1. If someone has the ability in your organization to configure your server properly then you're good to go.

    2. Try using your .htaccess file to set the appropriate $_SERVER variable. See this or google around a little bit.

    3. Write a plugin that manually sets the host to the appropriate value:
    public function Base_AfterAnalyzeRequest_Handler($Sender, $Args) {
    Gdn::Request()->RequestHost('EXAMPLE.COM');
    }
  • Options
    After a lot of reading and fumbling I worked around the problem with via ugly hack. I was unable to get any control over the HTTP_HOST variable, the hosting server is buried under lot of proxies and gateways which I have no control over. However I do have control over the actual host server, so I just set up the ServerName to the desired value and then hacked the library/core/class.request.php file like so:

    // UGLY HACK -- below //$this->RequestHost(isset($_SERVER['HTTP_HOST']) ? ArrayValue('HTTP_HOST',$_SERVER) : ArrayValue('SERVER_NAME',$_SERVER)); $this->RequestHost(ArrayValue('SERVER_NAME',$_SERVER));

    So that it only gets the SERVER_NAME when it asks for the host. I would go for option 3 if only my php knowledge weren't so rudimentary. :(
  • Options
    TimTim Operations Vanilla Staff
    Are you hosting behind a reverse proxy like nginx?

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • Options
    I don't know much on the subject however I know that there is a reverse proxy involved at some point(s). A friend of mine who saw the server values of HTTP_X_FORWARDED_HOST pointed that out to me. Further than that I just know that we are funneled through a SQUID proxy, but not sure what and if might have any implication on the matter.
Sign In or Register to comment.