How to setup suffix proxy server - proxy

Can anyone guide me for setting up suffix proxy server , so that user can access some specific sites cached in our campus server without doing any configuration in their browsers.
by suffix proxy i mean that if user wants to open http: //en.wikipedia.org/wiki/Proxy_server page then he should enter link:
http ://en.wikipedia.org.CAMPUSPROXY.NET/wiki/Proxy_server (where campusproxy.net is our proxy server) and this requested page can be retrived from our proxy server in place of wikipedia.org

It's a redirect really - your server needs to have a url check that will catch the prefix portion of the url and for this you obviously need unlimited prefix's available from the registered domain URI then it just reforms the uri of the prefix makes the request for the page and then presents it as content to the user - normally you'll also inject a banner at the top of the page also.
so it goes
User - http-get en.wikipedia.org.CAMPUSPROXY.NET/wiki/Proxy_server
your server takes this and creates "en.wikipedia.org/wiki/Proxy_server" via a script or what have you.
CAMPUSPROXY.NET http-get en.wikipedia.org/wiki/Proxy_server
inject the banner code into the webpage via a script or what have you.
probably also modify the html tags and headers to include your prefix proxy info
some knowledge of python - perl or whatever is all you need together with apache or similar server, their are of course scripts out there already but if you do that you'll learn nothing.

Related

HAProxy Redirect URL

I am using HAProxy 1.8, I need to make redirection rules, but I do not know the tool well, I have tried but it fails me in some particular cases with different clients.
Client Applications: Adobe Flex 3 (Web) and .Net (Web, WebServices and Desktop).
Necessary redirection example:
Current URL: http://oldsite.com/WS/WSInfo/WSDataClient
URL redirection: http://web1.site.com/WS/WSInfo/WSDataClient
I must perform several redirects (so I have to repeat the rule many times), I can not redirect all "olsite.com" to "web1.site.com", since both balancers will have concurrent calls, not all services, "http://oldsite.com" will stop being used.
The rule of HAProxy:
###----SERV_WSInfo_WSDataClient_test
acl withwsdl_SERV_WSInfo_WSDataClient url /WS/WSInfo/WSDataClient_test?wsdl
acl notwsdl_SERV_WSInfo_WSDataClient path_beg /WS/WSInfo/WSDataClient_test
http-request redirect location http://web1.site.com/WS/WSInfo/WSDataClient?%[query] code 301 if withwsdl_SERV_WSInfo_WSDataClient
http-request redirect location http://web1.site.com/WS/WSInfo/WSDataClient code 301 if notwsdl_SERV_WSInfo_WSDataClient
This works in the Flex applications that consume it, but not in the .Net point, I have been able to detect that:
Flex calls WSDL twice from the service (I suspect that by the redirect of the rule), but it works.
.Net, on the other hand, never asks for the WSDL and the service returns error, blank response.
Someone can recommend how would be the correct way to implement the
rule to achieve the necessary redirection.
To redirect an HTTPS with that same URL, should I add more logic?
They think that I'm not using the necessary tool to do it, they can recommend another one (currently HAProxy is used but if I manage to make it work in another Proxy, I could ask to evaluate).
I thank you for your help since I do not use the tool and I am not from the network area.
Given they are both on different HAProxy servers makes it a bit easier as you dont need to worry about an acl for the new domain. Here is a simple acl that doesnt worry about the querystring at all.
acl is_SERV_TEST url_beg -i /WS/WSInfo/WSDataClient
This acl checks the beginning of the url (case insensitive with the -i) against our url we need to redirec the prefix (host).
http-request redirect code 301 prefix http://web1.site.com if is_SERV_TEST
The redirection simply changes the prefix and maintains the remainder of the URL. For this reason we dont need to worry about the query string etc.
Full Code
acl is_SERV_TEST url_beg -i /WS/WSInfo/WSDataClient
http-request redirect code 301 prefix http://web1.site.com if is_SERV_TEST
SSL Question
For SSL related rewrites this is a double edge sword, and this is against the requirement of the company. For example if you want all request from http://oldsite.com to go to the SSL (HTTPS) url for web1.site.com then you should be doing that in your 301 redirect.
So you would simply change the rewrite prefix to https://web1.site.com.
Finally if you also need to mange the 301 redirect for ssl (ie over port 443) you should create another listener frontend binding to :443 and use the same rules as your port :80 listener.

How to add tomcat virtual hosts instances programatically

I was working for the last 2 years on building a social network for companies using Grails.
A new requirement appeared which is creating separate virtual host for each company that will have it's own database of users, timelines, etc (I would like to avoid rewriting all the service layer)
So initially the application was running on http://www.my-social-network.com for example
Now using an admin console that we will have to develop, companies should be able to create their own subdomain like this : http://company1.my-social-network.com and so on.
The web server that we are using is Apache 2.2 + tomcat 6
Is there someone who has an idea about how to do it?
Ideally I want to have one instance of the application that receives requests with different host names so it can behave differently in order to save resources because Grails consumes too much memory.
For example :
subdomain1.my-social-network.com --> apache 2 --> my-social-network.com (+ specific headers) --> tomcat
If such thing was possible, is there a way to select a datasource depending on a request parameter or header?
Any help is appreciated
There are a number of different options you can take, but first you need to make a decision on how you are going to implement this at the lowest level:
You can take the requests to subdomain1.my-social-network.com and redirect the user to my-social-network.com.
Same as above but use HTTP 302, HTTP 303 or HTTP 307 instead.
Simply show the contents of the site, responding with HTTP 200 (probably the best approach as these domains are meant to be permanent). Further text assumes this option.
Next, you need to have a servlet filter which intercepts all HTTP traffic and has a map {virtual_path -> real_site}. This filter can simply set relevant request attribute (hint: servletRequest.setAttribute(String, Object)) when it detects that requested virtual path is recognized.
If a user creates/renames/deletes a domain/virtual path, you would populate the map accordingly.
Finally, your render component should check that parameter and render relevant site. It is really hard to elaborate further without knowing more details on how your application works.

Programmatically pass additional header info along with URL to open a browser

I have an application which at one point wants to launch a particular URL in the default browser. This is pretty simple and can be achieved using ShellExecute on Windows. However the catch is that the server expects some additional custom header information (for authentication/identification purposes) to be sent along with the GET request.
Is there any way by which this (additional header) information could be passed to the browser while launching it?
Note:- I want to launch the default browser and not use a Web browser control
As I understand you have only one option: add intermidiate page (in internet or on localhost).
You have to create yoursite.com/sendHeaders.php or localhost/sendHeaders.php (or any another extension; choose language what do you prefer), which does following:
Unpack parameters (URL and headers),
Connect to the URL, send the headers,
Print the answer in browser.
So you will open in your browser intermediate page yoursite.com/sendHeaders.php?url=realUrl&headers=packedHeaders, but browser will show you a page realUrl, which received proper headers.

mod_rewrite and server environment variables

The setup I have is as follows:
I have one Apache server acting as a URL rewriting engine (SERVER1).
I have a second server (Apache too) which runs a web application (SERVER2). First tries to authenticate users. Part of the authentication protocol involves a lot of redirection between that application server and the authentication server.
My problem is that once the authencation is successfull, the authentication server needs to redirect the user back to the application server, which is only visible from SERVER1. Effectively, SERVER2 needs to be able to reconstruct a URL based on SERVER1's parameters.
Most of the environement variable are helpful i.e. I know the host name, script name, page called etcc but I can 't figure out wether the call was made through HTTP or HTTPS: that information is wiped in the rewrite process by SERVER1...
Anybody knows if/how I can get that information through environement variables? I am limited in that I can't use query string parameters...
Thanks all !
This may sound strange, but I have found part of the answer to my question.
The rewrite engine (at least in Apache 2, I haven't looked anywhere else) allows for writting extra request header.
The rule should look something like that.
RewriteRule .* -
[E=INFO_PATH_INFO:%{PATH_INFO},NE]
Put simple, it creates a new header called INFO_PATH_INFO and sets the value to PATH_INFO.
( For more info check out http://www.askapache.com/htaccess/crazy-advanced-mod_rewrite-tutorial.html )
Then it can be retrieved in any languages.
For info I am using Oracle's OWA which adds an extra layer of complication due to the fact that the default environment variables are limited to a few and additional variables need to be specified in thr dads.conf
Hope this will help anyone !

Accessing a file in another server from GWT Client side

I have a file, sample.xml located at one web server. I want to access this file from a GWT application running at another server. I dont want to make RPC calls to the same server serving GWT application and access the required file on server side (like a proxy). I want to access the file directly from client side as my application is going to be hosted as static files in a web server.
Is there a way to do that?
Sure - you must issue a XHR (XmlHTTPRequest) from the browser, and then parse the data.
In GWT you can do it using the RequestBuilder class (see here).
Please note that some client side restrictions may apply (e.g. Single Origin Policy etc.)
You issue the request (GET or POST - GET in your case) and pass a callback instance.
The instance's onResponseReceived method receives a Response object, which by calling its getText method returns the received contents.
You're trying to have your website (a.com/index.html) reference b.com/sample.xml. I see a few options.
If you have access to b.com's servers:
Edit sample.xml into sample.js to contain the same information in JSON with a callback, and reference it with a script tag
Compile your website using the cross-site loader (see Controlling Compiler Output), put your index.html at b.com/index.html, put all the rest of your files on a.com. Then all your RPC calls can go to b.com, but this means the user would have to navigate to b.com instead of a.com
If you don't have access to b.com's servers:
- Simply provide a link for people to download sample.xml
- Host a.com on a server with some kind of script support (PHP, Python, Ruby, Java, anything) and put a proxy to b.com/sample.xml

Resources