Configurar GlasFish Producción 1

1. Quitar la página de incio: http://localhost:8080/
Reemplazar el index.html de la ruta ...\glassfish3.1\glassfish\domains\domain1\docroot\  por otro que no revele la información de del servidor.

2. Reemplazar la página de errores del GF
Fuente: http://duckranger.com/2010/08/configure-a-custom-404-page-in-glassfish/
Fuente: http://stackoverflow.com/questions/2317514/how-to-change-glassfishs-default-error-page

2.1 De la instancia General
c:\glassfish\domains\mydomain\config\domain.xml

<virtual-server hosts="${com.sun.aas.hostName}" http-listeners="http-listener-1,http-listener-2" id="server"  log-file="${com.sun.aas.instanceRoot}/logs/server.log" state="on">
    <property name="docroot" value="${com.sun.aas.instanceRoot}/docroot"/>
    <property name="accesslog" value="${com.sun.aas.instanceRoot}/logs/access"/>
    <property name="sso-enabled" value="false"/>
</virtual-server>

<virtual-server hosts="${com.sun.aas.hostName}" http-listeners="http-listener-1,http-listener-2" id="server"  log-file="${com.sun.aas.instanceRoot}/logs/server.log" state="on">
    <property name="docroot" value="${com.sun.aas.instanceRoot}/docroot"/>
    <property name="accesslog" value="${com.sun.aas.instanceRoot}/logs/access"/>
    <property name="sso-enabled" value="false"/>
    <property name="send-error_1" value="path=../applications/j2ee-apps/myapplicationcontext/myapplication_war/404.html reason=Resource_not_found code=404"/>
</virtual-server>

The name is just a unique name. If you need to add more error pages – just increase the number with each one.

2.2 Configurar en la aplicación.
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
   version="2.5">
    <error-page>
        <error-code>404</error-code>
        <location>/404.html</location>
    </error-page>
    ..



3. Ocultar el nombre del server y la versión de la cabecera de respuesta.
Fuente: https://blogs.oracle.com/alexismp/entry/chameleon_glassfish_x_powered_by

3.1. X-Powered-By: quitar en el check en Configuration > Network Config > Network Listeners > http-listener-1 > HTTP

>asadmin set server.network-config.protocols.protocol.http-listener-1.http.xpowered-by=false

% curl -I http://localhost:8080 
HTTP/1.1 200 OK 
Server: GlassFish Server Open Source Edition 3.0.1 
Accept-Ranges: bytes 
ETag: W/"5212-1259789398000" 
Last-Modified: Wed, 02 Dec 2009 21:29:58 GMT 
Content-Type: text/html 
Content-Length: 5212 
Date: Tue, 07 Sep 2010 10:02:27 GMT


3.2. Server: Configuration > JVM Settings > JVM Options)

% asadmin create-jvm-options -Dproduct.name="My little server"
% asadmin restart-domain
Successfully restarted the domain
Command restart-domain executed successfully.
% curl -I http://localhost:8080
HTTP/1.1 200 OK
Server: My little server
Accept-Ranges: bytes
ETag: W/"5212-1259789398000"
Last-Modified: Wed, 02 Dec 2009 21:29:58 GMT
Content-Type: text/html
Content-Length: 5212
Date: Tue, 07 Sep 2010 10:20:16 GMT
Finally you can remove the "Server" header altogether by setting the property to an empty string :
% asadmin create-jvm-options -Dproduct.name=""
% asadmin restart-domain
Successfully restarted the domain
Command restart-domain executed successfully.
% curl -I http://localhost:8080
HTTP/1.1 200 OK
Accept-Ranges: bytes
ETag: W/"5212-1259789398000"
Last-Modified: Wed, 02 Dec 2009 21:29:58 GMT
Content-Type: text/html
Content-Length: 5212
Date: Tue, 07 Sep 2010 10:20:36 GMT












Comentarios

Entradas populares