Menu

#9 DetermineNameSpace and DetermineEndPoint enhanced to be used behind reverse Proxy

New
nobody
None
Medium
Enhancement
2012-08-26
2012-08-23
Anonymous
No

Originally created by: christia...@gmail.com
Originally owned by: schickwa...@googlemail.com

What steps will reproduce the problem?
1. Use php-wsdl-creater behind a Apache Reverse Proxy
2.
3.

What is the expected output? What do you see instead?
Use Reverse Proxy instead of App server name

What version of the product are you using? On what operating system?
SVN Trunk 20120812, Any ( win7-64/win7-32, windows 2003/windows 2008r2

Please provide any additional information below.

Code Fragment to enhance your code:
    /**
     * Determine the endpoint URI
     */
    public function DetermineEndPoint(){
    // HTTP / HTTPS
    if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
        $protocol = 'https';
    } else {
        $protocol = 'http';
    }

    // PORT
    if (isset($_SERVER['SERVER_PORT'])) {
        if (($protocol == 'https' && $_SERVER['SERVER_PORT'] != 443) ||
            ($protocol == 'http'  && $_SERVER['SERVER_PORT'] != 80)) {
            $port = ':'. $_SERVER['SERVER_PORT'];
        }else{
            $port =$_SERVER['SERVER_PORT'];
        }
    }
    // SERVER_NAME
    if (isset($_SERVER['X_FORWARDE_FOR'])) {
        $hostname=($_SERVER['X_FORWARDE_FOR'];
    }else{
        $hostname =$_SERVER['SERVER_NAME'];
    }
    return $protocol .'://'. $hostname . $port . $_SERVER['SCRIPT_NAME'];
}

    /**
     * Determine the namespace
     */
    public function DetermineNameSpace(){
            // SERVER_NAME
        if (isset($_SERVER['X_FORWARDE_FOR'])) {
            $hostname=($_SERVER['X_FORWARDE_FOR'];
        }else{
            $hostname =$_SERVER['SERVER_NAME'];
        }
        return 'http://'.$hostname.str_replace(basename($_SERVER['SCRIPT_NAME']),'',$_SERVER['SCRIPT_NAME']);
    }

Discussion

  • Anonymous

    Anonymous - 2012-08-24

    Originally posted by: christia...@gmail.com

    Small typhos:

        /**
         * Determine the endpoint URI
         */
        public function DetermineEndPoint(){
        // HTTP / HTTPS
        if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
            $protocol = 'https';
        } else {
            $protocol = 'http';
        }

        // PORT
        if (isset($_SERVER['SERVER_PORT'])) {
            if (($protocol == 'https' && $_SERVER['SERVER_PORT'] != 443) ||
                ($protocol == 'http'  && $_SERVER['SERVER_PORT'] != 80)) {
                $port = ':'. $_SERVER['SERVER_PORT'];
            }else{
                $port =$_SERVER['SERVER_PORT'];
            }
        }
        // SERVER_NAME
        if (isset($_SERVER['X_FORWARDED_FOR'])) {
            $hostname=$_SERVER['X_FORWARDED_FOR'];
        }else{
            $hostname =$_SERVER['SERVER_NAME'];
        }
        return $protocol .'://'. $hostname .':'. $port . $_SERVER['SCRIPT_NAME'];
    }

        /**
         * Determine the namespace
         */
        public function DetermineNameSpace(){
                // SERVER_NAME
            if (isset($_SERVER['X_FORWARDED_FOR'])) {
                $hostname=$_SERVER['X_FORWARDE_FOR'];
            }else{
                $hostname =$_SERVER['SERVER_NAME'];
            }
            return 'http://'.$hostname.str_replace(basename($_SERVER['SCRIPT_NAME']),'',$_SERVER['SCRIPT_NAME']);
        }

     
  • Anonymous

    Anonymous - 2012-08-26

    Originally posted by: christia...@gmail.com

    Now also as Patch file

    On more issue found: Line764 cause at demo.php
    //if(is_null($class)&&$this->IsOnlyGlobal()){
    +        if(!isset($class)&&$this->IsOnlyGlobal()){

    Tested with PHP Version 5.3.8, Apache, win7

     
  • Anonymous

    Anonymous - 2012-08-26

    Originally posted by: schickwa...@googlemail.com

    I'd prefer to init the $class variable with NULL, but thanks anyway!

    The XFF header (as all X-headers) is a very special thing - and it could be faked, so I'd prefer to set the PhpWsdl->EndPoint and PhpWsdl->NameSpace manually in this case. I had a look at the Apache documentation:

    http://httpd.apache.org/docs/trunk/mod/mod_proxy.html

    There the XFF header is described as "The IP address of the client"!? Are you sure you receive the server name when accessing this header?

    Labels: -Type-Defect Type-Enhancement
    Owner: schickwa...@googlemail.com

     
  • Anonymous

    Anonymous - 2012-08-26

    Originally posted by: christia...@gmail.com

    http://httpd.apache.org/docs/trunk/mod/mod_proxy.html#forwardreverse

    X-Forwarded-Host is correct not X-Forwarded-For

    Still this works as expected now in our reverse Proxy scenario

    I correct it to that, thanks

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.