IBM Edge Server: Criando Paginas de Erro Customizadas

From Wiki
Revision as of 18:31, 28 June 2012 by Ebasso (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Podemos customizar o IBM Edge Server para gerar arquivos com o estilo da empresa. Para isso realize os procedimentos abaixo:

Procedimento:

Criando o modelo

1) Crie um diretório c:\errorpages e adicione os css e imagens.

2) Crie um arquivo de modelo html de modelo para validar.

3) Após fechado o modelo, altera a função printFile, no script aplicativo java, para gerar os arquivos htmls.


Criando os arquivos com um java

Gere os arquivos utilizando o seguinte aplicativo java

import java.io.FileOutputStream;
import java.io.PrintStream;


public class MontaEdgeCustomMessages {


	public static void main(String[] args) {
		MontaEdgeCustomMessages run = new MontaEdgeCustomMessages();
		System.out.println("MontaEdgeCustomMessages - Start");
		run.runMain();
		System.out.println("MontaEdgeCustomMessages - End");
	}

	private void runMain() {

		//String sI = "";
		try {
			String dirName = "c://errorpages//"; 

			this.printFile(dirName +"badrange.htmls","Error 416 - Invalid request - Content range is incorrect.");
			this.printFile(dirName +"badredirect.htmls","Error 403 - Forbidden - invalid redirection in configuration file.");
			this.printFile(dirName +"badrequest.htmls","Error 400 - Invalid request - completely unable to parse it.");
			this.printFile(dirName +"badscript.htmls","Error 400 - Bad script request -- no script name.");
			this.printFile(dirName +"baduser.htmls","Error 403 - Forbidden - bad user directory.");
			this.printFile(dirName +"blocked.htmls","Error 403 - Blocked by filtering rule.");
			this.printFile(dirName +"byrule.htmls","Error 403 - Access forbidden by rule.");
			this.printFile(dirName +"cacheexp.htmls","Error 404 - Document was found in the cache, but it was expired.");
			this.printFile(dirName +"cachenoconn.htmls","Error 504 - Document was not found in the cache.");
			this.printFile(dirName +"cachenotopened.htmls","Error 500 - Proxy cache file could not be accessed.");
			this.printFile(dirName +"cacheonly.htmls","Error 504 - The requested document is not cached.");
			this.printFile(dirName +"connectfail.htmls","Error 400 - Proxy Error: Unable to connect to remote host or host not responding - URL ");
			this.printFile(dirName +"deletefailed.htmls","Error 500 - Unable to delete file.");
			this.printFile(dirName +"dirbrowse.htmls","Error 403 - Directory browsing failed - access forbidden.");
			this.printFile(dirName +"dirnobrowse.htmls","Error 403 - Directory browsing failed - unable to open directory (opendir).");
			this.printFile(dirName +"dotdot.htmls","Error 403 - Forbidden - URL containing .. forbidden.");
			this.printFile(dirName +"expectfailed.htmls","Error 417 - Expectation Failed.");
			this.printFile(dirName +"ftpanonloginrej.htmls","Error 504 - Proxy Error: Cannot login to the FTP Server anonymously.");
			this.printFile(dirName +"ftpauth.htmls","Error 400 - Proxy Error: Could not login to FTP Server.");
			this.printFile(dirName +"ftpbad220.htmls","Error 504 - Proxy Error: FTP Server did not send 220 connection message.");
			this.printFile(dirName +"ftphpanonloginrej.htmls","Error 400 - Proxy Error: Cannot login to the FTP Server anonymously.");
			this.printFile(dirName +"ftphpbad220.htmls","Error 504 - Proxy Error: FTP Server did not send 220 connection message.");
			this.printFile(dirName +"ftphploginrej.htmls","Error 400 - The requested user ID cannot login to the FTP Server.");
			this.printFile(dirName +"ftphpnoconnect.htmls","Error 400 - Proxy Error: Unable to connect to remote FTP Server at  or server not responding.");
			this.printFile(dirName +"ftphpnodata.htmls","Error 400 - Proxy Error: unable to open data connection for the FTP Server at .");
			this.printFile(dirName +"ftphpnoresponse.htmls","Error 400 - Proxy Error: No response from FTP Server at .");
			this.printFile(dirName +"ftphpnosocket.htmls","Error 400 - Proxy Error: Unable to open socket for FTP connection.");
			this.printFile(dirName +"ftphpunreshost.htmls","Error 400 - Proxy Error: Unable to resolve host name -");
			this.printFile(dirName +"ftploginrej.htmls","Error 504 - The requested user ID cannot login to the FTP Server.");
			this.printFile(dirName +"ftploginreq.htmls","Error 401 - Proxy Error: userid and/or password required for the FTP Server at");
			this.printFile(dirName +"ftpnoconnect.htmls","Error 504 - Proxy Error: Unable to connect to remote FTP Server at");
			this.printFile(dirName +"ftpnodata.htmls","Error 504 - Proxy Error: unable to open data connection for the FTP Server");
			this.printFile(dirName +"ftpnoresponse.htmls","Error 504 - Proxy Error: No response from FTP Server at");
			this.printFile(dirName +"ftpnosocket.htmls","Error 504 - Proxy Error: Unable to open socket for FTP connection.");
			this.printFile(dirName +"ftpunrechost.htmls","Error 400 - Proxy Error: Host name not recognized or host not found -");
			this.printFile(dirName +"ftpunreshost.htmls","Error 504 - Proxy Error: Unable to resolve host name -");
			this.printFile(dirName +"hpforbidden.htmls","Error 403 - Forbidden - Not Allowed.");
			this.printFile(dirName +"httpnodata.htmls","Error 400 - Proxy Error: Remote host did not send any data - URL");
			this.printFile(dirName +"httpnoforward.htmls","Error 400 - Proxy Error: Unable to forward request");
			this.printFile(dirName +"httpnosend.htmls","Error 400 - Proxy Error: Unable to send request");
			this.printFile(dirName +"httpunreshost.htmls","Error 400 - Proxy Error: Unable to resolve host name - URL");
			this.printFile(dirName +"ipmask.htmls","Error 403 - Forbidden - server refuses to serve to your IP address.");
			this.printFile(dirName +"ipmaskproxy.htmls","Error 403 - Proxy server will not serve to your IP Address (at least with this HTTP");
			this.printFile(dirName +"methoddisabled.htmls","Error 405 - Method is disabled on this server.");
			this.printFile(dirName +"multifail.htmls","Error 404 - Not found - file doesn't exist or is read protected [even tried multi].");
			this.printFile(dirName +"noaccess.htmls","Error 403 - Cannot access the requested file.");
			this.printFile(dirName +"noacl.htmls","Error 403 - Forbidden - access to file is never allowed [no ACL file].");
			this.printFile(dirName +"nocachenoconn.htmls","Error 400 - Internal proxy cache standalone mode error;");
			this.printFile(dirName +"noentry.htmls","Error 403 - Forbidden - access to file is never allowed [no ACL entry].");
			this.printFile(dirName +"noformat.htmls","Error 406 - No acceptable representation.");
			this.printFile(dirName +"nohostheader.htmls","Error 400 - Invalid request -- HOST header was not sent.");
			this.printFile(dirName +"noopen.htmls","Error 403 - Cannot open file.");
			this.printFile(dirName +"nopartner.htmls","Error 400 - Proxy Error: Host name not recognized or host not found - URL");
			this.printFile(dirName +"norep.htmls","Error 403 - Could not find suitable representation for transmission.");
			this.printFile(dirName +"notallowed.htmls","Error 403 - Forbidden - PUT/DELETE must be explicitly allowed in server's protection");
			this.printFile(dirName +"notauthorized.htmls","Error 401 - Not Authorized - Authentication failed.");
			this.printFile(dirName +"notfound.htmls","Error 404 - Not found");
			this.printFile(dirName +"notmember.htmls","Error 401 - Not authorized to access the document.");
			this.printFile(dirName +"olproxnocontact.htmls","Error 400 - Outer-level proxy could not be contacted.");
			this.printFile(dirName +"openfailed.htmls","Error 403 - Cannot browse the selected file.");
			this.printFile(dirName +"originbadresp.htmls","Error 500 - Origin Server returned invalid response.");
			this.printFile(dirName +"outputtimeout.htmls","Error 504 - Proxy Time-out ");
			this.printFile(dirName +"preconfail.htmls","Error 412 - Precondition failed: Could not match entity tags");
			this.printFile(dirName +"proxybadurl.htmls","Error 400 - Proxy Error: Invalid URL.");
			this.printFile(dirName +"proxyfail.htmls","Error 400 - Proxy load failed.");
			this.printFile(dirName +"proxynotauth.htmls","Error 407 - Not authorized. Proxy-Authentication failed (or your browser does not");
			this.printFile(dirName +"proxynotmember.htmls","Error 407 - Not authorized for proxy access to the document.");
			this.printFile(dirName +"putfailed.htmls","Error 500 - Unable to put file.");
			this.printFile(dirName +"rchunkerror.htmls","Error 502 - An incorrectly formatted chunked message was received.");
			this.printFile(dirName +"rchunkmemory.htmls","Error 500 - Proxy Error: Unable to continue receiving chunked message.");
			this.printFile(dirName +"scriptinterr.htmls","Error 500 - Internal error: execve() failed.");
			this.printFile(dirName +"scriptio.htmls","Error 500 - Internal error: can't read script output pipe.");
			this.printFile(dirName +"scriptnocomm.htmls","Error 500 - Could not communicate with CGI program.");
			this.printFile(dirName +"scriptnotfound.htmls","Error 500 - Bad preparse script request -- script is not executable");
			this.printFile(dirName +"scriptnovari.htmls","Error 500 - Bad script request -- no variation is executable.");
			this.printFile(dirName +"scriptstart.htmls","Error 500 - Starting the CGI program failed.");
			this.printFile(dirName +"servermaperror.htmls","Error 500 - Server mapping error. The server is misconfigured.");
			this.printFile(dirName +"setuperror.htmls","Error 403 - Forbidden - server protection setup error [probably protection setup file");
			this.printFile(dirName +"throttled.htmls","Error 503 - This server cannot accept any more requests right now.");
			this.printFile(dirName +"unknownmethod.htmls","Error 501 - The request is not valid or not recognized.");

		}
		catch (Exception e){
			System.err.println(e);
		}
	}

	private void printFile(String fileName, String ErrorMessage) throws Exception{
		FileOutputStream saida;
		PrintStream fileSaida;
		
		saida = new FileOutputStream(fileName);
		fileSaida = new PrintStream(saida);
		
		fileSaida.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");

Colocar o seu código aqui, usuando a função fileSaida.println

	}

}


Colocando os arquivos em produção

Vá para o diretório de configuração do edge

# cd /opt/ibm/edge/cp/server_root/pub/en_US

Faça um backup do arquivos originais

# mv errorpages errorpages_orig

Crie o novo diretório

# mkdir erropages
# cd errorpages

Coloque os arquivos criados no novo diretório


Ajustando a configuração no ibmproxy.conf

Vá para o diretório de configuração do edge

# cd /opt/ibm/edge/cp/etc/en_US 

Edite o arquivo ibmproxy.conf

ErrorPage badrange              /errorpages/badrange.htmls
ErrorPage badredirect           /errorpages/badredirect.htmls
ErrorPage badrequest            /errorpages/badrequest.htmls
ErrorPage badscript             /errorpages/badscript.htmls
ErrorPage baduser               /errorpages/baduser.htmls
ErrorPage blocked               /errorpages/blocked.htmls
ErrorPage byrule                /errorpages/byrule.htmls
ErrorPage cacheexp              /errorpages/cacheexp.htmls
ErrorPage cachenoconn           /errorpages/cachenoconn.htmls
ErrorPage cachenotopened        /errorpages/cachenotopened.htmls
ErrorPage cacheonly             /errorpages/cacheonly.htmls
ErrorPage connectfail           /errorpages/connectfail.htmls
ErrorPage deletefailed          /errorpages/deletefailed.htmls
ErrorPage dirbrowse             /errorpages/dirbrowse.htmls
ErrorPage dirnobrowse           /errorpages/dirnobrowse.htmls
ErrorPage dotdot                /errorpages/dotdot.htmls
ErrorPage expectfailed          /errorpages/expectfailed.htmls
ErrorPage ftpanonloginrej       /errorpages/ftpanonloginrej.htmls
ErrorPage ftpauth               /errorpages/ftpauth.htmls
ErrorPage ftpbad220             /errorpages/ftpbad220.htmls
ErrorPage ftphpanonloginrej     /errorpages/ftphpanonloginrej.htmls
ErrorPage ftphpbad220           /errorpages/ftphpbad220.htmls
ErrorPage ftphploginrej         /errorpages/ftphploginrej.htmls
ErrorPage ftphpnoconnect        /errorpages/ftphpnoconnect.htmls
ErrorPage ftphpnoresponse       /errorpages/ftphpnoresponse.htmls
ErrorPage ftphpnosocket         /errorpages/ftphpnosocket.htmls
ErrorPage ftphpunreshost        /errorpages/ftphpunreshost.htmls
ErrorPage ftploginrej           /errorpages/ftploginrej.htmls
ErrorPage ftploginreq           /errorpages/ftploginreq.htmls
ErrorPage ftpnoconnect          /errorpages/ftpnoconnect.htmls
ErrorPage ftpnodata             /errorpages/ftpnodata.htmls
ErrorPage ftpnoresponse         /errorpages/ftpnoresponse.htmls
ErrorPage ftpnosocket           /errorpages/ftpnosocket.htmls
ErrorPage ftpunrechost          /errorpages/ftpunrechost.htmls
ErrorPage ftpunreshost          /errorpages/ftpunreshost.htmls
ErrorPage hpforbidden           /errorpages/hpforbidden.htmls
ErrorPage httpnodata            /errorpages/httpnodata.htmls
ErrorPage httpnoforward         /errorpages/httpnoforward.htmls
ErrorPage httpnosend            /errorpages/httpnosend.htmls
ErrorPage httpunreshost         /errorpages/httpunreshost.htmls
ErrorPage ipmask                /errorpages/ipmask.htmls
ErrorPage ipmaskproxy           /errorpages/ipmaskproxy.htmls
ErrorPage methoddisabled        /errorpages/methoddisabled.htmls
ErrorPage multifail             /errorpages/multifail.htmls
ErrorPage noaccess              /errorpages/noaccess.htmls
ErrorPage noacl                 /errorpages/noacl.htmls
ErrorPage nocachenoconn         /errorpages/nocachenoconn.htmls
ErrorPage noentry               /errorpages/noentry.htmls
ErrorPage noformat              /errorpages/noformat.htmls
ErrorPage nohostheader          /errorpages/nohostheader.htmls
ErrorPage noopen                /errorpages/noopen.htmls
ErrorPage nopartner             /errorpages/nopartner.htmls
ErrorPage norep                 /errorpages/norep.htmls
ErrorPage notallowed            /errorpages/notallowed.htmls
ErrorPage notauthorized         /errorpages/notauthorized.htmls
ErrorPage notfound              /errorpages/notfound.htmls
ErrorPage notmember             /errorpages/notmember.htmls
ErrorPage olproxnocontact       /errorpages/olproxnocontact.htmls
ErrorPage openfailed            /errorpages/openfailed.htmls
ErrorPage originbadresp         /errorpages/originbadresp.htmls
ErrorPage preconfail            /errorpages/preconfail.htmls
ErrorPage proxybadurl           /errorpages/proxybadurl.htmls
ErrorPage proxyfail             /errorpages/proxyfail.htmls
ErrorPage proxynotauth          /errorpages/proxynotauth.htmls
ErrorPage proxynotmember        /errorpages/proxynotmember.htmls
ErrorPage putfailed             /errorpages/putfailed.htmls
ErrorPage rchunkerror           /errorpages/rchunkerror.htmls
ErrorPage rchunkmemory          /errorpages/rchunkmemory.htmls
ErrorPage scriptinterr          /errorpages/scriptinterr.htmls
ErrorPage scriptio              /errorpages/scriptio.htmls
ErrorPage scriptnocomm          /errorpages/scriptnocomm.htmls
ErrorPage scriptnotfound        /errorpages/scriptnotfound.htmls
ErrorPage scriptnovari          /errorpages/scriptnovari.htmls
ErrorPage scriptstart           /errorpages/scriptstart.htmls
ErrorPage servermaperror        /errorpages/servermaperror.htmls
ErrorPage setuperror            /errorpages/setuperror.htmls
ErrorPage throttled             /errorpages/throttled.htmls
ErrorPage unknownmethod         /errorpages/unknownmethod.htmls
ErrorPage outputtimeout         /errorpages/outputtimeout.htmls

Salve e feche o arquivo

Reinicie o serviço

# service ibmproxy stop
# service ibmproxy start