Re: [pgAdmin][RM4768] Reverse proxy on non-standard port

Aditya Toshniwal <[email protected]>
Newsgroups gmane.comp.db.postgresql.pgadmin.devel
Message-ID <CAM9w-_mRhcST+8mAmRaiWOYbRD9B4SmA2xv5gPBooAR=n+ACXA@mail.gmail.com>
Hi Hackers,

I have added a backward compatible code in cases werkzeug is older. This
will never happen considering we use Flask 1.0.2.
Attached is the precautionary patch.

On Fri, Sep 27, 2019 at 1:29 PM Akshay Joshi <[email protected]>
wrote:

> Thanks, patch applied.
>
> On Fri, Sep 27, 2019 at 12:17 PM Aditya Toshniwal <
> [email protected]> wrote:
>
>> Hi Hackers,
>>
>> Attached is the patch to allow pgAdmin to run behind reverse proxy on a
>> non standard port.
>> The middleware -
>> https://werkzeug.palletsprojects.com/en/0.15.x/middleware/proxy_fix/#werkzeug.middleware.proxy_fix.ProxyFix
>> allows us to set the number of trusted ports (and few other params) behind
>> the proxy. By default it is zero.
>> With this patch, user can set these params using pgAdmin config.
>> I have set the default value for port as 1, which will allow to run
>> behind non-standard port.
>>
>> I have added the documentation under reverse proxy section.
>>
>> Kindly review.
>>
>> --
>> Thanks and Regards,
>> Aditya Toshniwal
>> Sr. Software Engineer | EnterpriseDB India | Pune
>> "Don't Complain about Heat, Plant a TREE"
>>
>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
>
> *Sr. Software Architect*
> *EnterpriseDB Software India Private Limited*
> *Mobile: +91 976-788-8246*
>


-- 
Thanks and Regards,
Aditya Toshniwal
Sr. Software Engineer | EnterpriseDB India | Pune
"Don't Complain about Heat, Plant a TREE"
RM4768.oldwerkzeug.patch (application/octet-stream, 467 B)
diff --git a/web/pgAdmin4.py b/web/pgAdmin4.py
index 4bcfccc5..eb234e5c 100644
--- a/web/pgAdmin4.py
+++ b/web/pgAdmin4.py
@@ -13,7 +13,12 @@ to start a web server."""
 
 import os
 import sys
-from werkzeug.middleware.proxy_fix import ProxyFix
+
+try:
+    from werkzeug.middleware.proxy_fix import ProxyFix
+except ImportError:
+    # In case, werkzeug is older
+    from werkzeug.contrib.fixers import ProxyFix
 
 if sys.version_info[0] >= 3:
     import builtins
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.