Redirect whole browser traffic to restlet proxy

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Redirect whole browser traffic to restlet proxy

Jovan Jovanovic
Hi everybody,

after a lot of tries to build a proxy server I found it really easy using Restlet. Although I have an obvious issue after setting all the traffic from Chrome to go through my proxy, I get redirection loop (as also the routed URL is trying to go through proxy). Here is the code that I am using:

 public static void main(String[] args) throws Exception {
    Component component = new Component();
    component.getClients().add(Protocol.HTTP);
    component.getServers().add(Protocol.HTTP, 8111);
    Application application = new RestletProxy();   component.getDefaultHost().attachDefault(application);
        component.start();
    }
    @Override
    public Restlet createInboundRoot() {
      Router router = new Router(getContext());
      String target = "http://www.google.com";
      Redirector redirector = new  Redirector(getContext(), target);
      router.attachDefault(redirector);
      return router;
    }

So I am just trying to redirect every single request to google. Is it possible using restlet?

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3089543
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: Redirect whole browser traffic to restlet proxy

Jerome Louvel-3
Hi Jovan,

Are you trying to setup a reverse proxy (server-side)?
If so, you need to set the mode to MODE_SERVER_OUTBOUND and use an URI template such as  "http://www.google.com/{rr}".

See Javadocs as well:
http://restlet.com/learn/javadocs/snapshot/jee/api/org/restlet/routing/Redirector.html

Best regards,
Jerome

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3089931
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Redirect whole browser traffic to restlet proxy

Xybrek
In reply to this post by Jovan Jovanovic
On Tuesday, 07 October, 2014 08:12 PM, Jovan Jovanovic wrote:

> Hi everybody,
>
> after a lot of tries to build a proxy server I found it really easy using Restlet. Although I have an obvious issue after setting all the traffic from Chrome to go through my proxy, I get redirection loop (as also the routed URL is trying to go through proxy). Here is the code that I am using:
>
>   public static void main(String[] args) throws Exception {
>      Component component = new Component();
>      component.getClients().add(Protocol.HTTP);
>      component.getServers().add(Protocol.HTTP, 8111);
>      Application application = new RestletProxy();   component.getDefaultHost().attachDefault(application);
>          component.start();
>      }
>      @Override
>      public Restlet createInboundRoot() {
>        Router router = new Router(getContext());
>        String target = "http://www.google.com";
>        Redirector redirector = new  Redirector(getContext(), target);
>        router.attachDefault(redirector);
>        return router;
>      }
>
> So I am just trying to redirect every single request to google. Is it possible using restlet?
>
> ------------------------------------------------------
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3089543
>

I just want to share that yes it is possible, I have a running proxy in
heroku that runs Restlet proxy and redirects all traffic to a given URL

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3093682
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Redirect whole browser traffic to restlet proxy

Thierry Boileau-4
thanks!

have a good day,
Thierry Boileau

2015-01-03 20:41 GMT+01:00 Xybrek <[hidden email]>:
On Tuesday, 07 October, 2014 08:12 PM, Jovan Jovanovic wrote:
> Hi everybody,
>
> after a lot of tries to build a proxy server I found it really easy using Restlet. Although I have an obvious issue after setting all the traffic from Chrome to go through my proxy, I get redirection loop (as also the routed URL is trying to go through proxy). Here is the code that I am using:
>
>   public static void main(String[] args) throws Exception {
>      Component component = new Component();
>      component.getClients().add(Protocol.HTTP);
>      component.getServers().add(Protocol.HTTP, 8111);
>      Application application = new RestletProxy();   component.getDefaultHost().attachDefault(application);
>          component.start();
>      }
>      @Override
>      public Restlet createInboundRoot() {
>        Router router = new Router(getContext());
>        String target = "http://www.google.com";
>        Redirector redirector = new  Redirector(getContext(), target);
>        router.attachDefault(redirector);
>        return router;
>      }
>
> So I am just trying to redirect every single request to google. Is it possible using restlet?
>
> ------------------------------------------------------
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3089543
>

I just want to share that yes it is possible, I have a running proxy in
heroku that runs Restlet proxy and redirects all traffic to a given URL

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3093682



--
Thierry Boileau, Mr B


6 Rue Rose Dieng-Kuntz • Nantes, 44300  France
Loading...