setting pypes for virtual hosting

17 views
Skip to first unread message

Jayesh

unread,
Feb 17, 2012, 1:45:27 PM2/17/12
to pypes
Hi,

First of all thanks for a nice library and a framework. We have been
using Pypes for our project and this week we ran into a issue.
Basically we have pypes server running as well as a tomcat server that
provides some additional services we needed. Pypes is running on port
5000 and tomcat is running on port 8080. We needed to post some data
from pypes front end (ui) to our JSP page hosted by tomcat. I was
trying to use AJAX but then ran into the issue of cross domain.

To resolve the issue I setup virtual hosting for tomcat and pypes and
configured Tomcat for it. Now tomcat is working but I could not really
figure out how to setup pypes for virtual hosting, meaning what
configuration I need to provide to pypes for virtual hosting. I looked
at existing option in production.ini but didn't find anything useful.


Any help related to this will be very helpful.

Thanks,

Matt Weber

unread,
Feb 17, 2012, 3:57:40 PM2/17/12
to py...@googlegroups.com
I would leave pypes running on 5000 and tomcat on 8080.  I would then setup nginx to proxy requests back to each of these services.  Doing this both will live in the same domain and appear to be running on the same port thus avoiding the cross domain issue.


Something like:


location /tomcat {
    proxy_pass              http://localhost:8080;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        Host $http_host;
  }                                                                                                        
  location /pypes {
    proxy_pass              http://localhost:5000;
    proxy_set_header        X-Real-IP $remote_addr;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header        Host $http_host;
  }

Good luck.

-- 
Matt Weber
Sent with Sparrow

egaumer

unread,
Feb 18, 2012, 9:16:32 AM2/18/12
to py...@googlegroups.com
I would just enable Cross Origin Resource Sharing (CORS) which allows website owners to control who can access data via Javascript AJAX requests. 


Enabling this on tomcat should allow you to successfully POST data from pypes (providing you use a modern browser). Here is a CORS filter that should work with tomcat.


Aashish Chaudhary

unread,
Feb 18, 2012, 10:34:15 AM2/18/12
to py...@googlegroups.com
Thanks Matt! I will give a try.

Aashish Chaudhary

unread,
Feb 18, 2012, 10:35:00 AM2/18/12
to py...@googlegroups.com
Great! seems like a simple setup. Thanks for sharing this.
Reply all
Reply to author
Forward
0 new messages