# CPU info more /proc/cpuinfo # Memory info dmidecode -t memory dmidecode -t memory | grep -i "installed size" # Operatin System cat /etc/os-release hostnamectl uname -r
Buscar este blog
martes, 14 de abril de 2020
CentOS check system info
Show system inf for a CentOS server:
sábado, 11 de abril de 2020
SoapUI escape dollar variable "${}"
If you need to escape "${some-text}" you have to put "$${some-text}"
viernes, 10 de abril de 2020
Axis 1 - SLF4J Logging
In this post I´ll show you how to configure Axis 1 Logging with SLF4J-Log4j. The main purpose is to trace incoming and outcoming messages.
Axis uses Apache commons-logging as logging implementation. This dependecy is configured as runtime in Axis pom, so it will not be imported as transitive.
Any way, if you have commons-logging library in your project, exclude it.
As you exclude commons-logging, you need to add the corresponding slf4j bridge, i.e., jcl-over-slf4j library.
Add a file called common-logging.properties in src/main/resoruces with the following content:
When you configure log4j logging, for example in log4j.xml file, add the following categories:
org.apache.axis.providers is used by web service providers in order to trace incoming messages and outcoming responses.
org.apache.axis.transport.http is used by web service clientes in order to trace outcoming messages and incoming responses.
Axis uses Apache commons-logging as logging implementation. This dependecy is configured as runtime in Axis pom, so it will not be imported as transitive.
Any way, if you have commons-logging library in your project, exclude it.
As you exclude commons-logging, you need to add the corresponding slf4j bridge, i.e., jcl-over-slf4j library.
Add a file called common-logging.properties in src/main/resoruces with the following content:
org.apache.commons.logging.LogFactory=org.apache.commons.logging.impl.SLF4JLogFactory
When you configure log4j logging, for example in log4j.xml file, add the following categories:
<logger name="org.apache.axis.providers" additivity="false"> <level value="debug"/> <appender-ref ref="FILE"/> </logger> <logger name="org.apache.axis.transport.http" additivity="false"> <level value="debug"/> <appender-ref ref="FILE"/> </logger>
org.apache.axis.providers is used by web service providers in order to trace incoming messages and outcoming responses.
org.apache.axis.transport.http is used by web service clientes in order to trace outcoming messages and incoming responses.
sábado, 28 de marzo de 2020
CentOS 6 - Port forwarding
I have the following scenario:
Configure forwarding:
Here you have:
You can check the configuration as follow:
Check the rules and delete them one by one:
- My computer
- CentOS 6.5 intermediate server IP_CENTOS
- Third party service: https://IP_SERVICE/domain/service-path
From my computer I can reach the CentOS server, but not the third party service.
From CentOS server you can reach the third party service.
I want to use CentOS server as a bridge in order to forward traffic from my computer to the third party service and vice versa.
Set configuration
Step 1
Enable ip forward in iptables:
echo 1 >/proc/sys/net/ipv4/ip_forward
Step 2
iptables -t nat -A PREROUTING -p tcp --dport 9443 -j DNAT --to-destination [IP_SERVICE]:443 iptables -t nat -A POSTROUTING -p tcp -d [IP_SERVICE] --dport 443 -j SNAT --to-source [IP_CENTOS]
Here you have:
- 9443 is the fake port used in CentOS server.
- IP_SERVICE is the IP address of the third party service
- 443 is the default HTTPS port, as the third party service is in https://xxxxxx
- IP_CENTOS is the IP address of the CentOS server
Step 3
Save the rules:
service iptables save service iptables reload
You can check the configuration as follow:
iptables -t nat --line-numbers -L more /etc/sysconfig/iptables
Test
From My Computer you can check to access to https://IP_CENTOS:9443/domain/service-path
Rollback configuration
In order to restore configuration and delete all previous work, do as follows:
echo 0 >/proc/sys/net/ipv4/ip_forward
Check the rules and delete them one by one:
iptables -t nat --line-numbers -L iptables -t nat -D PREROUTING|POSTROUTING [num]
jueves, 19 de marzo de 2020
Apache Camel - Proxy route
In this example I will configure a Camel route proxy. Camel will publish a http servlet and redirect all request to a external provider.
Configuration
You need to configure as follow:- Configure dependencies
- Configure Camel servlet
- Configure Camel route
Configure dependencies
In pom.xml:
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-servlet</artifactId> <version>${camel.version}</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-http4</artifactId> <version>${camel.version}</version> </dependency>
Configure Camel servlet
In web.xml:
Or, alternatively, in java:
<servlet> <servlet-name>CamelServlet</servlet-name> <display-name>Camel Http Transport Servlet</display-name> <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>CamelServlet</servlet-name> <url-pattern>/services/*</url-pattern> </servlet-mapping>
Or, alternatively, in java:
import javax.servlet.annotation.WebServlet; @WebServlet(name = "CamelServlet", urlPatterns = { "/services/*" }, loadOnStartup = 1) public class CamelRestServlet extends org.apache.camel.component.servlet.CamelHttpTransportServlet { private static final long serialVersionUID = 2886685336873526067L; //Servlet secuestrado por Camel para procesar las peticiones de entrada a su ruta proxy }
Configure Camel route
In camel-context.xml:
<camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="servlet:/service1?matchOnUriPrefix=true"/> <log message="Redirecting to service1"/> <to uri="http4://otherDomain:8080/otherApp/service1?bridgeEndpoint=true&throwExceptionOnFailure=false"/> </route> <route> <from uri="servlet:/service2?matchOnUriPrefix=true"/> <log message="Redirecting to service2"/> <to uri="http4://otherDomain:8080/otherApp/service2?bridgeEndpoint=true&throwExceptionOnFailure=false"/> </route> </camelContext>
Testing
In your app is published in http://localhost:8080/myApp, then you will get the following behaviour:
When calling http://localhost:8080/myApp/services/service1/test?a=b Camel will redirect to http://otherDomain:8080/otherApp/service1/test?a=b
Suscribirse a:
Entradas (Atom)