Giter Site home page Giter Site logo

apacheproxygenerator's Introduction

Apache proxy file generator

Small tool for internal use at Nelen & Schuurmans (but it might be useful as an example for others).

Place a .ini file somewhere (suggestion: /etc/apache2/) and place sites in there, grouped by server:

[p-web-ws-00-d04.external-nens.local]
demo.lizard.net
almere.lizard.net https
www.deltaportaal.nl

[s-web-ws-00-d3.external-nens.local]
test.almere.lizard.net

Call the generate_proxy.py script and give it the ini file and a conf file as output location. The conf file will be replaced if it already exists. The output will look like:

# Lizard Web demo.lizard.net on p-web-ws-00-d04.external-nens.local
<VirtualHost *:80>
    ServerName demo.lizard.net
    ProxyPreserveHost On
    ProxyPass / http://p-web-ws-00-d04.external-nens.local/
    ProxyPassReverse / http://p-web-ws-00-d04.external-nens.local/
</VirtualHost>
# Permanent redirect from www.* to the without-www domain.
<VirtualHost *:80>
    ServerName www.demo.lizard.net
    RewriteEngine On
    RewriteRule  "^(.*)" "http://demo.lizard.net$1" [R=301,L]
</VirtualHost>

So two things happen per site:

  • The requests are proxied to the server under which header you placed the DNS name.
  • A www. is prepended and given a permanent redirect to the non-www site. Note that this is reversed in case you yourself place a www site name in there.
  • If https is placed after the site name, a redirect from http to https is added. This depends on the Pound setup we have in place now, btw.

It is handy to place a script somewhere (suggestion: /usr/local/bin/generate_proxy) with a content like this:

#!/bin/sh
INI=/etc/apache2/generated_proxy.ini
CONF=/etc/apache2/sites-available/generated_proxy.conf
/root/apacheproxygenerator/generate_proxy.py $INI $CONF
apache2ctl configtest
echo "If succesful, run 'apache2ctl graceful'"

apacheproxygenerator's People

Contributors

reinout avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.