Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Linux proxy routing Node.js , +
Hello,
 
I have configured my dedicated server to link domains with default port (80) to my nodejs ports accordingly to domain name. E.g. site1.com to port 2222 and site2.com to port 3333.
 
My question is how to pass a subdomain name as a parameter, e.g.:
param1.site1.com:80 should go to 127.0.0.1:2222/param1
 
My haproxy config:
global
    log 127.0.0.1 local0
    log 127.0.0.1 local1 notice
    maxconn 4096
    user haproxy
    group haproxy
    daemon
 
defaults
    log global
    mode http
    option httplog
    option dontlognull
    retries 3
    option redispatch
    maxconn 2000
    contimeout 5000
    clitimeout 50000
    srvtimeout 50000
 
frontend http-in
    bind *:80
    acl is_www_site1_com hdr_end(host) -i site1.com
    acl is_www_site2_com hdr_end(host) -i site2.com
    
    use_backend www_site1_com if is_www_site1_com
    use_backend www_site2_com if is_www_site2_com
    default_backend www_site1_com
 
backend www_site1_com
    balance roundrobin
    cookie SERVERID insert nocache indirect
    option httpchk HEAD /check.txt HTTP/1.0
    option httpclose
    option forwardfor
    server Server1 127.0.0.1:2222 cookie Server1
 
backend www_site2_com
    balance roundrobin
    cookie SERVERID insert nocache indirect
    option httpchk HEAD /check.txt HTTP/1.0
    option httpclose
    option forwardfor
    server Server1 127.0.0.1:3333 cookie Server1
 
I hope someone knows answer Smile | :) Thanks!
Posted 30-Apr-13 23:31pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

If haproxy redirects the site to the specific server and port, the host name should still stay the same in the users browser so you should be able to extract the subdomain from the hostname and then redirect on the site to the specific folder relating to the subdomain such as Apache's RewriteEngine or using a php or Node.js module on the server itself??
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 382
1 DamithSL 275
2 OriginalGriff 245
3 Zoltán Zörgő 149
4 Dave Kreskowiak 110
0 OriginalGriff 7,575
1 DamithSL 5,529
2 Sergey Alexandrovich Kryukov 5,279
3 Maciej Los 4,961
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 9 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100