Pontus Ullgren HTTP Proxy flow in Mule ESB CE

Created by Pontus Ullgren last modified
# ------------------------------------------------------------------------------ #
# Java defaults (https://github.com/github/gitignore/blob/master/Java.gitignore) #
# ------------------------------------------------------------------------------ #
*.class

# Package Files #
*.jar
*.war
*.ear

# ------------------------------------------------------------------------------------------- #
# Eclipse-specific (https://github.com/github/gitignore/blob/master/Global/Eclipse.gitignore) #
# ------------------------------------------------------------------------------------------- #
*.pydevproject
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
# You may want to remove the sharp symbols here if you are using Maven 
.project
.classpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpath

# --------------- #
# Studio-specific #
# --------------- #
.studio/
flows/
target/
**/*.mflow
1
2
3
4
5
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<mule-project xmlns="http://www.mulesoft.com/tooling/project" runtimeId="org.mule.tooling.server.3.6.1" schemaVersion="3.5.0.0">
    <name>httpproxy</name>
    <description></description>
</mule-project>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

	<modelVersion>4.0.0</modelVersion>
	<groupId>com.ullgren.pontus.demo</groupId>
	<artifactId>httpproxy</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>mule</packaging>
	<name>Mule httpproxy Application</name>

    <properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

		<mule.version>3.6.1</mule.version>
    	<mule.tools.version>1.0</mule.tools.version>
	</properties>

	<build>
		<plugins>
			<plugin>
				<groupId>org.mule.tools.maven</groupId>
				<artifactId>mule-app-maven-plugin</artifactId>
				<version>${mule.tools.version}</version>
				<extensions>true</extensions>
				<configuration>
                    <copyToAppsDirectory>true</copyToAppsDirectory>
				</configuration>
			</plugin>
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<version>2.2.1</version>
				<configuration>
					<descriptorRefs>
						<descriptorRef>project</descriptorRef>
					</descriptorRefs>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<version>1.7</version>
				<executions>
					<execution>
						<id>add-resource</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>add-resource</goal>
						</goals>
						<configuration>
							<resources>
								<resource>
									<directory>src/main/app/</directory>
								</resource>
								<resource>
									<directory>mappings/</directory>
								</resource>
							<resource>
                                    <directory>src/main/api/</directory>
                                </resource>
                            </resources>
						</configuration>
					</execution>
				</executions>
			</plugin>
		<plugin>
                <groupId>org.mule.munit.tools</groupId>
                <artifactId>munit-maven-plugin</artifactId>
                <version>3.6.0-BETA</version>
                <executions>
                    <execution>
                        <id>test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
	<testResources>
            <testResource>
                <directory>src/test/munit</directory>
            </testResource>
        </testResources>
    </build>

	<!-- Mule Dependencies -->
	<dependencies>
		<!-- Xml configuration -->
		<dependency>
			<groupId>org.mule.modules</groupId>
			<artifactId>mule-module-spring-config</artifactId>
			<version>${mule.version}</version>
			<scope>provided</scope>
		</dependency>
		<!-- Mule Transports -->
		<dependency>
			<groupId>org.mule.transports</groupId>
			<artifactId>mule-transport-file</artifactId>
			<version>${mule.version}</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.mule.transports</groupId>
			<artifactId>mule-transport-http</artifactId>
			<version>${mule.version}</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.mule.transports</groupId>
			<artifactId>mule-transport-jdbc</artifactId>
			<version>${mule.version}</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.mule.transports</groupId>
			<artifactId>mule-transport-jms</artifactId>
			<version>${mule.version}</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.mule.transports</groupId>
			<artifactId>mule-transport-vm</artifactId>
			<version>${mule.version}</version>
			<scope>provided</scope>
		</dependency>
		<!-- Mule Modules -->
		<dependency>
			<groupId>org.mule.modules</groupId>
			<artifactId>mule-module-scripting</artifactId>
			<version>${mule.version}</version>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.mule.modules</groupId>
			<artifactId>mule-module-xml</artifactId>
			<version>${mule.version}</version>
			<scope>provided</scope>
		</dependency>
		<!-- for testing -->
		<dependency>
			<groupId>org.mule.tests</groupId>
			<artifactId>mule-tests-functional</artifactId>
			<version>${mule.version}</version>
			<scope>test</scope>
		</dependency>
	<dependency>
            <groupId>org.mule.munit</groupId>
            <artifactId>munit-assert</artifactId>
            <version>3.6.0-BETA</version>
            <scope>test</scope>
        </dependency>
    <dependency>
            <groupId>org.mule.munit</groupId>
            <artifactId>munit-mock</artifactId>
            <version>3.6.0-BETA</version>
            <scope>test</scope>
        </dependency>
    <dependency>
            <groupId>org.mule.munit</groupId>
            <artifactId>munit-common</artifactId>
            <version>3.6.0-BETA</version>
            <scope>test</scope>
        </dependency>
    <dependency>
            <groupId>org.mule.munit</groupId>
            <artifactId>munit-runner</artifactId>
            <version>3.6.0-BETA</version>
            <scope>test</scope>
        </dependency>
    <dependency>
            <groupId>org.mule.modules</groupId>
            <artifactId>mule-interceptor-module</artifactId>
            <version>3.6.0-BETA</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

	<repositories>
          <repository>
            <id>Central</id>
            <name>Central</name>
            <url>http://repo1.maven.org/maven2/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>mulesoft-releases</id>
            <name>MuleSoft Releases Repository</name>
            <url>http://repository.mulesoft.org/releases/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>mulesoft-snapshots</id>
            <name>MuleSoft Snapshots Repository</name>
            <url>http://repository.mulesoft.org/snapshots/</url>
            <layout>default</layout>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>mulesoft-release</id>
            <name>mulesoft release repository</name>
            <layout>default</layout>
            <url>http://repository.mulesoft.org/releases/</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

</project>
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
	xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.6.1"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd">

	<http:listener-config name="http-lc-0.0.0.0-8081" host="0.0.0.0" port="8081" />
	<http:request-config name="http-request-config" host="localhost" port="8888"/>

	<flow name="proxy" doc:name="HTTP Proxy" doc:description="Proxy flow will forward all incoming requests on port 8081 to localhost:8888.">
		<http:listener path="/*" config-ref="http-lc-0.0.0.0-8081" />
		<flow-ref name="copyRequestHeaders" doc:name="Copy and sanitize request headers" />
		<http:request config-ref="http-request-config" method="#[message.inboundProperties['http.method']]" path="#[message.inboundProperties['http.request.path'].substring(message.inboundProperties['http.listener.path'].length()-2)]" parseResponse="false">
            <http:request-builder>
                <http:query-params expression="#[message.inboundProperties['http.query.params']]"/>
            </http:request-builder>
            <http:success-status-code-validator values="0..599" />
        </http:request>
        <flow-ref name="copyResponseHeaders" doc:name="Copy and sanitize response headers" />
	</flow>
	
	<flow name="copyRequestHeaders">
		<copy-properties propertyName="*"/>
        <remove-property propertyName="Host"/>
        <remove-property propertyName="MULE_*"/>
        <remove-property propertyName="Connection"/>
        <remove-property propertyName="http.*"/>
        <remove-property propertyName="expect"/>
	</flow>
	
	<flow name="copyResponseHeaders">
		<copy-properties propertyName="*"/>
        <remove-property propertyName="Host"/>
        <remove-property propertyName="MULE_*"/>
        <remove-property propertyName="Connection"/>
        <remove-property propertyName="Transfer-Encoding"/>
        <remove-property propertyName="Server"/>
	</flow>
</mule>
1
2
3
4
5
#Mon Jul 13 22:02:32 CEST 2015
redeployment.enabled=true
encoding=UTF-8
domain=default
config.resources=httpproxy.xml

Comments (0)