On Fri, 20 Nov 2015 09:32:02 GMT, Louie Bacani Foronda wrote:

I would like to pass requests from first.com and second.com to a single server is this possible?

so basically what I am thinking is to run

first.com in port 8080
and
second.com to 8081

in the dns I only put the server ip..
first.com server.ip
second.com server.ip

now I need to run something on port 80 right then just pass the requests to the ports...

I only have access to a single ip and server...

I'd generally also recommend to use Nginx for this - simply set up two virtual hosts with the proper reverse proxy directives. The advantage is that you can make use of the more advanced feature set to for example better fight against certain types of DOS attacks.

However, I'm using a vibe.d based solution for the vibe.d sites to have some more test exposure for it's own components and it's running well and stable for me, too. The core of the application looks similar to this:

import vibe.vibe;

HTTPServerRequestDelegate proxy(ushort port)
{
	auto settings = new HTTPReverseProxySettings;
	settings.destinationHost = "127.0.0.1";
	settings.destinationPort = port;
	settings.avoidCompressedRequests = true;
	return reverseProxyRequest(settings);
}

shared static this()
{
	ushort[string] host_map = [
		"first.com" : 8080,
		"second.com": 8081
	];

	foreach( host, port; host_map ){
		auto settings = new HTTPServerSettings;
		settings.hostName = host;
		settings.port = 80;
		// no advanced request processing necessary
		settings.options = HTTPServerOption.none;
		listenHTTP(settings, proxy(port));
	}
}