Skip to content

configure trasparent proxy

Daniele Fontani edited this page Sep 2, 2017 · 2 revisions

this configuration allow to navigate a remote site through the proxy server. In this configuration all traffic is routed to destination.

To implement this for an host, we just need few configurations steps. Assume "proxy.local" is the url that clients will surf, and "destination.remote" is the real server.

/conf/vhosts/conf.json

this file contains the settings about main configuration. Here we have to tell:

  • there is a new host to list: proxy.local, telling on what port server will get requests
  • what module are needed. This sample show only the ones required. Other module can be left (modules are activated only basing on vhost settings) So for this part you can basically left all untouched.
  • what configuration use for this site. *SettingsName:..."
{
  "BalancerSettings": {
    "Mappings": [
      
      {
        "Host": "proxy.local:52231",
        "SettingsName": "proxy_sample"
      }
    ],
    "Plugins": [
      {
        "Name": "Init",
        "Impl": "NetLoadBalancer.Code.Middleware.InitMiddleware"
      },
      {
        "Name": "Proxy",
        "Impl": "NetLoadBalancer.Code.Middleware.ProxyMiddleware"
      }
    ]

/conf/vhosts/proxy_sample.conf

To keep settings clean such settings are on dedicated files under vhost folder. The name of the file must be the same of the one specified into conf.json file. In this case is "proxy_sample" but you can put here whatever you want.

This file basically state that:

  • We need the proxy module
  • we listen the source and serve resources from destination
{
  "proxy_sample": {
    "Host": "proxy.local",
    "Port": 52231,
    "Scheme": "http",
    "Filters": [ "Proxy" ],
    "Settings": {
      "Proxy": {
        "DefaultDestination": {
          "Host": "destination.local",
          "Port": 443,
          "Scheme": "https"
        }
      }
    }
  }
}