Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Dev Section Scripting / API
  • Search

Enabling web-domain-proxy

Questions regarding the API
Application Programming Interface
Locked
  • Print view
Advanced search
6 posts • Page 1 of 1
Graham
Posts: 57
Joined: Wed Sep 25, 2013 6:32 pm

Enabling web-domain-proxy

Post by Graham » Sat Oct 19, 2013 11:39 pm

I'm trying to add a web domain proxy via the api.

It works fine using the command line:

Code: Select all

v-add-web-domain-proxy ted test.test.com
but when I try this through the API I get an error:

Error: argument extentions is not valid (empty)

Code: Select all

function createWebDomainProxy($server,$admuser,$admpa,$proxyDomain)
{
	// Prepare variables
	$postvars1 = array(
	  'user' => $admuser,
	  'password' => $admpa,
	  'cmd' => 'v-add-web-domain-proxy',
	  'arg1' => 'ted',
	  'arg2' => $proxyDomain
	);
	$postdata = http_build_query($postvars1);
//echo $postdata;
	// Get current status
	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, 'https://' . $server . ':8083/api/');
	curl_setopt($curl, CURLOPT_RETURNTRANSFER,true);
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
	curl_setopt($curl, CURLOPT_POST, true);
	curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
	$answer = curl_exec($curl);
	return $answer;
}
$server = '192.0.0.0';
$admuser = 'admin';
$admpa = 'topsecret';
$domain = 'test.test.com'
echo createWebDomainProxy($server,$admuser,$admpa,$domain);
Top

Graham
Posts: 57
Joined: Wed Sep 25, 2013 6:32 pm

Re: Enabling web-domain-proxy

Post by Graham » Sun Oct 20, 2013 12:00 am

It doesn't appear to like commas in the extensions argument via the api, even the default ones in the v-add-web-domain-proxy script (when I don't pass extensions in the api).

If I change my script to add arg3 and arg4, it only runs if arg4 contains a single extension.

This works:

Code: Select all

'arg4' => 'htm'
This doesn't:

Code: Select all

'arg4' => 'jpg, htm'
Top

Graham
Posts: 57
Joined: Wed Sep 25, 2013 6:32 pm

Re: Enabling web-domain-proxy

Post by Graham » Sun Oct 20, 2013 12:37 am

This does:

Code: Select all

	  'arg4' => 'jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm',//DEBUG ME
Is there a requirement with the api that all arguments need to be provided (even if blank)?
It looks like arg4 in v-add-web-domain-proxy doesn't like comma space
htm, jpeg, jpg = BAD
htm,jpeg,jpg = GOOD
Top

skid
VestaCP Team
Posts: 1476
Joined: Wed Apr 06, 2011 11:12 pm

Re: Enabling web-domain-proxy

Post by skid » Sun Oct 20, 2013 7:59 am

Well you already figured out how it works :) Extension list should be always defined and spaces are not allowed
Top

Graham
Posts: 57
Joined: Wed Sep 25, 2013 6:32 pm

Re: Enabling web-domain-proxy

Post by Graham » Sun Oct 20, 2013 9:59 am

skid wrote:Well you already figured out how it works :) Extension list should be always defined and spaces are not allowed
I'm getting there skid (slowly). :)

The default extension list (that's used when none are specified) does contain spaces though, this causes the script to error.
Top

skid
VestaCP Team
Posts: 1476
Joined: Wed Apr 06, 2011 11:12 pm

Re: Enabling web-domain-proxy

Post by skid » Sun Oct 20, 2013 3:31 pm

I see. The web interface have some basic validation logic and it chops spaces and carriage returns prior sending.
Top


Locked
  • Print view

6 posts • Page 1 of 1

Return to “Scripting / API”



  • 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
 

 

Login  •  Register

I forgot my password