Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


nginx reverse proxy setup with apache. multiple domains on same IP
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

nginx reverse proxy setup with apache. multiple domains on same IP

navaronenavarone Member
edited December 2017 in Help

i have a small vps that is running 3 blogs on apache. all of these use the same IP
now i want to setup an nginx proxy on a different server but only for 1 domain, not all 3.

problem is
website1.com opens when i add the vps IP in browser http://1.2.3.4
website2.com and website3.com are also on same IP but they dont open with direct ip like website1.com

I want to use reverse proxy for website2.com but when i use this configuration with the IP, it creates reverse proxy for website1.com and not website2.com. what to do? please help

Comments

  • navaronenavarone Member
    edited December 2017

    please help

  • RTFM?
    http://nginx.org/en/docs/http/request_processing.html

    "in this configuration, the default server is the first one". Which means, if the host requested by your visitor (e.g. the pure IP...) is not specifically found in the nginx conf file, then it falls back to using the first host existing in your conf file.

  • so what is the solution?

  • Still can't understand what you're trying to achieve.

    (Please be more precise, use correct punctuation to separate your ideas, problem statement, expected outcome, unexpected results etc.)

  • look.
    i have 1 vps hosting 3 websites. VPS has 1 IP and its shared among all website.
    when i make reverse proxy on another vps for the 1st VPS on which sites are hosted, I enter IP for vps in nginx configuration (proxy_pass). but then when I open reverse proxy, it loads content for the primary domain on the IP on the 1st VPS.

    so i have 3 domains that share 1 IP and I want to setup a reverse proxy for a specific domain sharing that IP. i dont know how I can make myself more clear.

  • In your first message, it's not clear at all.

    "but when i use this configuration with the IP" (which IP ?????) "it creates reverse proxy" (who creates a reverse proxy? some bot?)

    Tell me ("yes"/"no") if that's your current setup :

    • one VPS, ip 1.2.3.4, running Apache as a web server, with three VirtualHosts (website1.com, website2.com, website3.com)

    • another VPS, ip 6.7.8.9, running nginx as a reverse proxy, passing anything and everything ($host) to the first VPS

    Now tell us what you get when some external visitor types this in their browser :

    • website1.com -> what do they see?

    • website2.com -> what do they see?

    • website3.com -> what do they see?

    • http://1.2.3.4 -> what do they see?

    • http://6.7.8.9 -> what do they see?

  • use different port on proxy pass or proxy pass using their using their own domain/subdomain or sub directory depend on how your server setup.

  • @navarone I would advise you to not waste your time with nginx until you are sure apache can't keep up with the traffic after the web server is scaled to the maximum size and and optimized. Modern apache can host multiple domains with TLS.

  • mkshmksh Member
    edited December 2017

    Imo it should work as long you pass the right host headers. Try changing:

    proxy_set_header Host $host;
    to
    proxy_set_header Host "website2.com";

    since unless website2.com is pointing at the IP of the proxy already $host wont be what you are expecting it to be. To be honest if thats the case i am not sure how you are accessing the proxy at all.

Sign In or Register to comment.