Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

VestaCP as Reverse Proxy to additional servers

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
5 posts • Page 1 of 1
MooFz
Posts: 9
Joined: Wed Sep 16, 2015 8:26 pm

VestaCP as Reverse Proxy to additional servers
  • Quote

Post by MooFz » Tue Jan 31, 2017 2:15 pm

Hey,

At home I have a DL380 runnin ESXi 6.5 with 4 virtual machines.
One of those virtual machines is running VestaCP, all other machines have their own web interfaces.
I only have one domain and 1 WAN IP address.

mydomain.com comes out on the VestaCP machine.
Now I would like to have sub1.mydomain.com to go to one of those other machines.
Is there a way to manage this from VestaCP?

Thanks in advance.
Top

mehargags
Support team
Posts: 1096
Joined: Sat Sep 06, 2014 9:58 pm
Contact:
Contact mehargags
Website Skype

Os: Debian 8x
Web: apache + nginx
Re: VestaCP as Reverse Proxy to additional servers
  • Quote

Post by mehargags » Tue Jan 31, 2017 2:54 pm

this has been discussed atleast a 100 times... pls use search, or even Google change VestaCP default domain
Top

jotab
Posts: 2
Joined: Mon Jan 23, 2017 12:29 am

Re: VestaCP as Reverse Proxy to additional servers
  • Quote

Post by jotab » Wed Feb 01, 2017 2:38 pm

I had some trouble achieving this at first, but after i read up a bit on how nginx works and how vesta handles things i came up with a custom template.

SSH to your machine and create a file called "proxy19216803.tpl" and one with the same name except it should have the file extension .stpl in the folder /usr/local/vesta/data/templates/web/nginx

The way I did it as I also wanted to force https is that I in the .tpl file put the following (from the force https template found elsewhere).

Code: Select all

server {
    listen      %ip%:%proxy_port%;
    server_name %domain_idn% %alias_idn%;
    location / {
        rewrite ^(.*) https://%domain_idn%$1 permanent;
    }
}
And in the .stpl file I put the following:

Code: Select all

server {
    listen      %ip%:%proxy_ssl_port%;
    server_name %domain_idn% %alias_idn%;
    ssl         on;
    ssl_certificate      %ssl_pem%;
    ssl_certificate_key  %ssl_key%;
    error_log  /var/log/%web_system%/domains/%domain%.error.log error;

    location / {
        proxy_pass      https://192.168.0.3:443/;
    }

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location @fallback {
        proxy_pass      https://%ip%:%web_ssl_port%;
    }

    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}

    include %home%/%user%/conf/web/snginx.%domain%.conf*;
}
You can probably remove most of the different locations except / in the .stpl file, but it does not interfer with my present config, so I just left it there.

What you then do is log in to VestaCP web panel, and choose "proxy support" in the settings of your subdomain and then in the proxy template choose the one with the name proxy19216803. What this does is that it will use the template you created and set up nginx to use it for your domain.
Top

dv8inpp1
Posts: 3
Joined: Tue Nov 07, 2017 2:09 am

Re: VestaCP as Reverse Proxy to additional servers
  • Quote

Post by dv8inpp1 » Tue Nov 07, 2017 4:42 am

Just wanted to say thanks for that. I better understand now how VestaCP does it's reverse proxy.
Top

pistolgrip
Posts: 5
Joined: Sat Aug 20, 2016 12:58 pm

Re: VestaCP as Reverse Proxy to additional servers
  • Quote

Post by pistolgrip » Fri Mar 08, 2019 4:07 pm

jotab wrote: ↑
Wed Feb 01, 2017 2:38 pm
I had some trouble achieving this at first, but after i read up a bit on how nginx works and how vesta handles things i came up with a custom template.

SSH to your machine and create a file called "proxy19216803.tpl" and one with the same name except it should have the file extension .stpl in the folder /usr/local/vesta/data/templates/web/nginx

The way I did it as I also wanted to force https is that I in the .tpl file put the following (from the force https template found elsewhere).

Code: Select all

server {
    listen      %ip%:%proxy_port%;
    server_name %domain_idn% %alias_idn%;
    location / {
        rewrite ^(.*) https://%domain_idn%$1 permanent;
    }
}
And in the .stpl file I put the following:

Code: Select all

server {
    listen      %ip%:%proxy_ssl_port%;
    server_name %domain_idn% %alias_idn%;
    ssl         on;
    ssl_certificate      %ssl_pem%;
    ssl_certificate_key  %ssl_key%;
    error_log  /var/log/%web_system%/domains/%domain%.error.log error;

    location / {
        proxy_pass      https://192.168.0.3:443/;
    }

    location /error/ {
        alias   %home%/%user%/web/%domain%/document_errors/;
    }

    location @fallback {
        proxy_pass      https://%ip%:%web_ssl_port%;
    }

    location ~ /\.ht    {return 404;}
    location ~ /\.svn/  {return 404;}
    location ~ /\.git/  {return 404;}
    location ~ /\.hg/   {return 404;}
    location ~ /\.bzr/  {return 404;}

    include %home%/%user%/conf/web/snginx.%domain%.conf*;
}
You can probably remove most of the different locations except / in the .stpl file, but it does not interfer with my present config, so I just left it there.

What you then do is log in to VestaCP web panel, and choose "proxy support" in the settings of your subdomain and then in the proxy template choose the one with the name proxy19216803. What this does is that it will use the template you created and set up nginx to use it for your domain.
I have been trying to get this working and not having much luck.

I am wanting to forward certain domains to different local machines.

If I set a domain to use the proxy template as you outlined above, the http://<somedomain>.com gets passed to the local ip/server as expected.

But, when I try to access the https://<somedomain>.com version I get a 500 Internal Server Error.

Hoping you may be able to provide some guidance? I don't see anything obvious in the logs.

Thanks!
Top


Post Reply
  • Print view

5 posts • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

cron

Login  •  Register

I forgot my password