Skip to content

Instantly share code, notes, and snippets.

View juliojsb's full-sized avatar
:octocat:
Focusing

Jota juliojsb

:octocat:
Focusing
View GitHub Profile
@juliojsb
juliojsb / httpd.conf
Created March 19, 2016 10:54
Hardening Apache security with TLS and secure ciphers order
Put this at Apache main configuration level (httpd.conf or apache2.conf) or even at VirtualHost level.
To enable only TLS (in all its versions):
SSLProtocol all -SSLv2 -SSLv3
SSLCompression off
SSLHonorCipherOrder on
SSLCipherSuite "ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA"
If you want to enable only TLS v1.2:
@juliojsb
juliojsb / persistence.xml
Created March 18, 2016 20:16
Optimization of Jboss applications. Enable second level hibernate cache in WEB-INF/classes/persistence.xml of an application
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<properties>
<property name="hibernate.cache.infinispan.statistics" value="true"/>
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.use_minimal_puts" value="true"/>
<property name="hibernate.cache.infinispan.entity.eviction.strategy" value= "LRU"/>
<property name="hibernate.cache.infinispan.entity.eviction.wake_up_interval" value= "2000"/>
<property name="hibernate.cache.infinispan.entity.eviction.max_entries" value= "6000"/>
<property name="hibernate.cache.infinispan.entity.expiration.lifespan" value= "60000"/>
<property name="hibernate.cache.infinispan.entity.expiration.max_idle" value= "30000"/>
@juliojsb
juliojsb / Jboss instance config file (standalone.xml, standalone-full-ha.xml...)
Created March 18, 2016 20:14
Automatic reconnect to database for Jboss EAP 6.x/AS7.x
In your datasource section define background validation:
<validation>
<check-valid-connection-sql>select 1 from dual</check-valid-connection-sql>
<background-validation>true</background-validation>
<validate-on-match>false</validate-on-match>
<background-validation-millis>15000</background-validation-millis>
</validation>
Or with validate on match:
@juliojsb
juliojsb / dont_show_pass_typing.sh
Created March 2, 2016 18:44
Read password variable in bash without showing the typing in the terminal
#!/bin/bash
# Read password from terminal without showing it
# read -s disables echo
echo -n "Enter your password: "
read -s password
# Show the password
echo -e "\nThe password you entered before -> $password"
@juliojsb
juliojsb / standalone-ha.xml
Created January 18, 2016 19:39
Jboss AS 7.X/6.X EAP TCP Cluster example
In standalone-ha.xml:
<subsystem xmlns="urn:jboss:domain:jgroups:1.1" default-stack="tcp">
<stack name="udp">
...
</stack>
<stack name="tcp">
<transport type="TCP" socket-binding="jgroups-tcp" diagnostics-socket-binding="jgroups-diagnostics"/>
<protocol type="TCPPING">
<property name="initial_hosts">192.168.2.101[7600],192.168.2.102[7600]</property>
@juliojsb
juliojsb / ip_virtualhosting_apache
Created November 29, 2015 13:54
An example of IP based Virtual Hosting in Apache
# VirtualHosting based on IP
Listen 80
# Site 1
<VirtualHost 192.168.2.101:80>
DocumentRoot "/var/www/html/site1"
ServerName www.site1.com
</VirtualHost>
@juliojsb
juliojsb / name_virtualhosting_apache
Last active November 29, 2015 13:52
An example of Name based Virtual Hosting in Apache
# Name based Virtual Hosting
Listen 80
# Site 1
<VirtualHost *:80>
DocumentRoot "/var/www/html/site1"
ServerName www.site1.com
</VirtualHost>
# Site 2
@juliojsb
juliojsb / port_virtualhosting_apache
Created November 29, 2015 13:52
An example of port based Virtual Hosting in Apache
# VirtualHosting based on ports
Listen 80
Listen 81
Listen 82
Listen 83
# Site 1
<VirtualHost *:80>
DocumentRoot "/var/www/html/site1"
ServerName www.site1.com
</VirtualHost>
@juliojsb
juliojsb / robots.txt
Created August 23, 2015 12:21
Robots.txt file for my website (http://www.juliojosesanz.com/robots.txt) useful for other Wordpress sites
# ---------------------------------------------------
# CRAWLERS/BOTS NOT ALLOWED
# ---------------------------------------------------
# Digg Mirror (Blocks Digg crawler)
User-agent: duggmirror
Disallow: /
# Alexa archiver
User-agent: ia_archiver
@juliojsb
juliojsb / apache-auth.conf
Created August 18, 2015 18:06
Added regex "^.*\[client <HOST>\:.*] AH01630: client denied by server configuration:" to /etc/fail2ban/filter.d/apache-auth.conf
# Fail2Ban apache-auth filter
#
[INCLUDES]
# Read common prefixes. If any customizations available -- read them from
# apache-common.local
before = apache-common.conf
[Definition]