TG 2.3.10 proxy-prefix problems

23 views
Skip to first unread message

zov...@gmail.com

unread,
Mar 23, 2017, 9:52:35 AM3/23/17
to TurboGears
Hi,

I mounted quickstarted Turbogears app (named testweb) behind NGINX under prefix testweb configured as folows:

server {                                                                                                              
        listen
8888;                                                                                                    
        server_name netcrawler
.esabor.intranet;                                                                        
        location
/testweb {
            proxy_pass                 http
://localhost:9991/;
            proxy_redirect             off
;
            proxy_set_header        
Host $host;
            proxy_set_header        X
-Real-IP $remote_addr;
            proxy_set_header        X
-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X
-Forwarded-Host $server_name;
            proxy_set_header        X
-Forwarded-Proto $scheme;
       
}
}



development.ini looks like:

[DEFAULT]
trace_errors
.from_address = turbogears@localhost
trace_errors
.smtp_server = localhost

[server:main]
use = egg:gearbox#wsgiref
host
= 0.0.0.0
port
= 9991

[filter:proxy-prefix]
use = egg:PasteDeploy#prefix
prefix
= /testweb

[app:main]
use = egg:testweb
filter_with
= proxy-prefix

etc
...



When I point browser to

http://netcrawler.esabor.intranet:8888/testweb

I am getting TG index page but links are wrong, for instance About points to http://netcrawler.esabor.intranet:8888/about instead of http://netcrawler.esabor.intranet:8888/testweb/about (all the links are missing testweb part).
When I try to log in manualy entering

http://netcrawler.esabor.intranet:8888/testweb/login

I can enter username and password but get redirected to

http://netcrawler.esabor.intranet:8888/login_handler?__logins=0&came_from=%2F (again without testweb part)

If I log in from different browser tab to gearbox instance

http://netcrawler.esabor.intranet:9991/login

 and complete log in process I can reach

http://netcrawler.esabor.intranet:8888/testweb/admin

and links on that page are OK.

Am I doing something wrong or need to additionaly configure something (or something is wrong with tg.url)?

Steps to replicate:

virtualenv dir
cd dir
source bin
/activate
pip install tg
.devtools
gearbox quickstart testweb
cd testweb
python setup
.py install


edit development.ini as above
edit nginx config file as above
restart nginx

gearbox setup-app
gearbox serve

With Best Regards

Ervin

Alessandro Molina

unread,
Mar 23, 2017, 6:30:31 PM3/23/17
to TurboGears
Make sure the PrefixMiddleware from Paste is properly setting the SCRIPT_NAME, if you print environ['SCRIPT_NAME'] that should contain your prefix.
If that's not the case check your configuration, for example I remember the filter option was filter-with not filter_with. Once SCRIPT_NAME is properly configured the generated urls should be correct.

--
You received this message because you are subscribed to the Google Groups "TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email to turbogears+unsubscribe@googlegroups.com.
To post to this group, send email to turbo...@googlegroups.com.
Visit this group at https://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/d/optout.

zov...@gmail.com

unread,
Mar 27, 2017, 4:28:06 AM3/27/17
to TurboGears
Typo was indeed the problem, now it works OK but I'm having problems logging in and out (will open new thread).

Thanks a lot.

Ervin
Reply all
Reply to author
Forward
0 new messages