Howdy, Stranger!

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

Advertise on LowEndTalk.com
OWN reverse proxy (one IP) for multiple sites
New on LowEndTalk? Please read our 'Community Rules' by clicking on it in the right menu!

OWN reverse proxy (one IP) for multiple sites

xrzxrz Member

Is it possible to create something like multiple reverse proxy, the one server will have installed nginx or similar software maybe apache_proxy and when someone request test1.com which will have in nameservers reverse proxy ip this will load from hidden server behind reverse proxy IP, but i want to have behind one reverse proxy IP multiple sites, so asking how?

Comments

  • Sure, using vhosts

  • xrzxrz Member

    i already have vhosts so 5 domains can exist on one server, but i want have those behind reverse proxy

  • JonchunJonchun Member, Provider
    edited January 2016

    Yes this is possible! Just do something like this

    server {
      listen 80;
      server_name example.com www.example.com;
      location / {
        proxy_pass http://localhost:8000;
        proxy_set_header Host            www.example.com;
        proxy_set_header X-Forwarded-For $remote_addr;
      }
    }
    

    So people will connect to your server on port 80 using example.com, get directed to your vhost server block, and for location / (all locations) they will be proxied to port 8000.

    Thanked by 1netomx
  • xrzxrz Member

    thx both :)

    but @Jonchun, can i have in nginx conf for port 80 more than 1 domain ?

  • JonchunJonchun Member, Provider

    @xrz said:
    thx both :)

    but Jonchun, can i have in nginx conf for port 80 more than 1 domain ?

    Yes of course. The above configuration should be for each of your virtual hosts.

  • Yes it's possible, I'm doing it caddyserver (was previously using Nginx) depending on which subdomain/domain you hit and the path depends which backend you get.

    It allows me to host multiple services/applications on port 443/80 on a single IP

  • xrzxrz Member

    thx guys! :)

  • wlambrechtswlambrechts Member
    edited January 2016

    As the example Jonchun gave ... I'm using to it have my Proxmox running on a single IPv4 address dispatch the HTTP request to any of the NATted guests (VMs) based on the requested domainname.

    I set it up using the info on this page: https://help.ubuntu.com/community/Nginx/ReverseProxy

  • xrzxrz Member
    edited January 2016

    can i do this on already cloudflare domain like this one???

    server {
      listen 80;
      server_name example.com www.example.com;
      location / {
        proxy_pass https://somecloudflaredomain.com;
        proxy_set_header Host            www.example.com;
        proxy_set_header X-Forwarded-For $remote_addr;
      }
    }
    
  • WHM Superb with the nginx reverse proxy install can do this under the default. The nginx will listen for all domains pointed to it and forward it to the backend cpanel server which hosts the actual website.

    BF/CM Grabs: 1-GeorgeDataCenter, 1-Netcup, 1-Avoro, 1-PHP-Friends, 1-Virtono, 1-AlphaVPS, 1-VirMach ($1/year!)
    Other VPS: 4-Virmachs

  • xaitmixaitmi Member
    edited January 2016

    This is one of the nginx reverse proxy confs I use for one of my sites.

    I use the reverse proxy as one of my sites get ddosed a lot.

    Note: This will make ur site accessible by SSL only, http will be automatically f/w'd to https

    server {
           listen         80;
           server_name    domain.com;
           return         301 https://$server_name$request_uri;
    }
    server {
          listen 443 ssl;
          server_name domain.com;
         
          ssl_certificate /home/ssl/cert.crt;
          ssl_certificate_key /home/ssl/cert.key;
    
          access_log   /home/logs/domain.access.log;
          error_log /home/logs/domain.error.log;
          
          location / {
                proxy_pass https://WEBSERVER IP/;
                proxy_redirect off;
                proxy_set_header Host $host;
                proxy_set_header X-Forwarded-SSL on;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_max_temp_file_size 0;
                client_max_body_size 10m;
                client_body_buffer_size 128k;
                proxy_connect_timeout 90;
                proxy_send_timeout 90;
                proxy_read_timeout 90;
                proxy_buffer_size 4k;
                proxy_buffers 4 32k;
                proxy_busy_buffers_size 64k;
                proxy_temp_file_write_size 64k;
    
          }
    }
    
Sign In or Register to comment.