Redirect to a web server depending on location with nginx - redirect

Im working on a web site that has to be reachable from many countries under the same domain.
Id like to know how can I receive a request with nginx (or any other static file server), and send it to different web servers depending on IP's location.
I mean, what is the point on having multiple db machines on country A and B, if the server that serves you the page is chosen by round robin.
Maybe theres another solution to my problem, and I would be very happy if someone can explain it to me.

It sounds like you are looking for a geographic page re-director.
This company provides a solution that will do the trick: www.geobytes.com
The idea is that your web server will redirect visitors to a location specific HTML page. So that, a guy in India that visits www.example.com will be shown a page customized for India, while a visitor from say Canada will see the Canadian home page.
It looks like they have PHP(http://forums.geobytes.com/viewtopic.php?f=9&t=6815) and Javascript APIs.
Some of their products are free, like the geographic page re-director(http://www.geobytes.com/GeoDirection.htm)
Hope it helps.

As stackoverflow is for programming issues, You’ll probably get a better response at https://serverfault.com/, which is geared toward “Networking, servers, or maintaining other people's PCs”. (See the FAQ.)

Related

How facebook detects my location so precisely only based on IP address?

I have two-step authentication on facebook. I just tried to log in from my home PC but didn't write second step code.
I've got notification that somebody (me) was trying to login to my account and location was so precise (within 2 meters).
I wondered how facebook detects location so precisely only based on IP?
Today geolocation is in the core business of Marketing companies, there's a very developped market of customer data, so tons of mobile apps and services collect data such as usual IP addresses, personal information, interests, locations.
That information gets reselled to data brokers, aggregated, corrected. And then Facebook or others can buy that data, merge it, implement corrections and so and get tables for matching IPs and locations that are not public, it seems.
However they offer a high level API to perform market targeting which seems to use that data:
https://developers.facebook.com/docs/marketing-api/buying-api/targeting#location
In your case it was precise because they may have a good dataset based on your privacy settings experience, not only with facebook but with other geo-located apps. In my case their guess is wrong by hundreds of Km, because I was behind a corporate proxy.

How to redirect a website according to country's IP address

I'm working on a messenger app whose server side code is developed in Erlang.
The problem which I'm facing is regarding redirection of website according to country specific domain.
For example: when user's types google.co in message box, it automatically displays google.co.uk, how can I redirect it to google.co.in if I'm in India?
For finding country's location, I found this library on github: https://github.com/mochi/egeoip
How can I use this geoLocation for redirecting to particular country specific website?
ScreenShot, when I entered facebook.com, it automatically displays preview in my local language.
But in case of my app, it shows preview in some foreign language, russian maybe.
I've read the comments, and since you are not considering having datasets as an option, I think what you may want to do is something like this:
First thing to understand is how those previews work. In any (popular) messaging app, if you type in a URL, the app will send a request to the URL and get the website metadata. Then it will be displayed in the UI.
The country detection, is a bit more complicated and done in a variety of ways. But thankfully, you (almost) don't have to do anything. This is a rather long topic, but I'll try to shorten it out.
Text Localization
In some websites (might be the case of Facebook's in your example), they do country detection on the application layer, and then based on that country, it will use a specific language for the website's text. This all usually happens before the website renders it's content, so you do not have to worry about it.
GeoDNS
This one occurs on the DNS layer, and probably the most popular. Domain names can be assigned a handful of IP addresses. These IPs can point to different versions of the website, and in the case of GeoDNS it will be up to the DNS manager to assign a country to an IP. So when a DNS query came from Russia, the requesting IP's country will be resolved and then the IP assigned to it (if any) will be returned. This is used by websites especially for country-specific features or content. Best example is Netflix.
Redirects
In case of Google redirecting you to a different domain, this might be how they do it. Country is being resolved via the IP address in the application (HTTP) layer, and then does a 301/302 redirect, pointing to the new domain name. This one, you may need to do something on. So given that your application needs to do an HTTP request to the URL the user has entered, if it returns a redirect, you must follow it. Many HTTP libs/clients already does this, but on some you might have to explicitly turn on the option to follow redirects.
One important thing to note is to do the HTTP request on the client side. Otherwise, you will be resolving to the same country (where your server resides) regardless of where your user is.

Masking an URL after redirect

We are building a SaaS solution which runs on SaaS.com for example. Our software should be white label for our resellers and their costumers. The costumers of our resellers are stored in an specific database witch is different for each reseller.
The reseller creates a button on his website [Login] which sends the customer resellerID.my.saas.com Our software gets the resellerID and selects the corresponding branding and database. This all works fine in an development environment at the moment.
We have only 1 thing which we need to solve and that is the url what the customer of the reseller sees in his browser. This is (after logging in) my.saas.com
We want that the customer of the reseller sees the domain of the reseller after they are redirected to our link (resellerid.my.saas.com), for example my.reseller.com
I googled a lot and asked our and 3th party developers how to solve this. Till now the only solution we found is using an iframe which has not our preference. This becouse this is not optimal for mobile views? and is out dated, isn't it?
I also tried to solve this with dns which i couldn't get done.
Is there any way to achieve what we want and when yes, how can we implement?
Hope on usefull responds becouse this part is verry crusial for our business.
Thanks in advance, Rogé

Is it possible to edit viewed profile data on Facebook and seen tweets on Twitter using a transparent proxy?

I'm setting up a network in which individuals see profile information of one friend, switched with that of another friend; such as likes, political views, etc.. Similarly for twitter, would see tweets tweeted by people who they follow. This would be editing only web interfaces of the two services.
I would like to have a transparent proxy on the network cache and serve the mangled pages; is this possible or even the correct way to attempt this? Thank you.
Since both Facebook and Twitter use HTTPS for their default connections, the correct term for what you're proposing is a Man-in-the-Middle attack. To do this you would need to do the following:
1) Deliberately misconfigure your proxy server to intercept HTTPS traffic.
2) Intercept the SSL/TLS handshake to get the session keys for each encrypted session.
There are commercial products which do this and are usually sold to businesses or government departments which need to monitor the activities of their staff, or who just want to.
A similar proposal was made around five years or so ago in Australia as part of the proposed Internet censorship regime. I wrote a report on that a year or so later and you might find it useful (PDF). Pages 6 to 10 deal with the part you're interested in, the technical methods by which it could be done.
Needless to say, I recommend against deliberately intercepting and interfering with your network users' secure communications. There would, after all, be no practical difference between interfering with their social media accounts and interfering with their bank accounts.

CMS for multiple domains in same language

We have a site which is based in US (ex. www.example.com). We've been tasked to create multiple sites for users of UK and Australia. Both of these will have different domains (ex. www.example.co.uk and www.example.co.au), These sites will share the same common pages backend. About 80% of the content is the same on all the versions but there will be a few sections like contact, partners and product offerings which are different
Example
US site (www.example.com) has 4 Pages:
Home
About
Products
Contact
UK Site (www.example.co.uk) also has the same pages
Home (The same as US with minor differences like the banner images. The URL will be www.example.co.uk)
About (Different content, the URL should be www.example.co.uk/about)
Products (The same as US with minor content diffences in the offering, but URL should be www.example.co.uk/services)
Contact (Different content, the URL should be www.example.co.uk/contact)
How do I go about setting up the UK and AU version of the site which use the same backend and most of the same content as the US site, but has a few page differences and different domain?
Can any one please recommend a few good CMS tools which will help achieve this?
as far as I can tell, most CMSes will be able to provide you with some form of content-sharing.
It does depend on the amount of content you are having, if you have a relatively small set (e.g. the 4 pages in your answer), then you might be best served by just duplicating the pages. If you are looking at tens, hundreds or more documents, then you should look at a properly structured approach.
Can you give some hints as to the amount of documents?
Note: I work for Hippo
Go for Typo3!
Supports Multi domain and Multi lingual sites very effectively.
Once the development for a single domain is over you don't even need a developer for adding more domains. That is you don't need to code for multi domains, just need to learn a few things.