From 8b5edb02a9789957941c1877dc4d79688eea8936 Mon Sep 17 00:00:00 2001 From: Amer Almadani Date: Mon, 5 Dec 2016 17:03:15 +0300 Subject: [PATCH] Added proxy configuration from http://www.ctrl-alt-del.cc/2014/11/haste-server-base-url-hackpatch.html --- Installation.md | 112 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 1 deletion(-) diff --git a/Installation.md b/Installation.md index a654503..304cc80 100644 --- a/Installation.md +++ b/Installation.md @@ -39,4 +39,114 @@ Use ebuild [www-apps/haste-server](https://github.com/cvut/gentoo-overlay/tree/m ## Cloudron You can get a hastebin setup running quickly using Cloudron: -https://cloudron.io/appstore.html#com.hastebin.cloudronapp \ No newline at end of file +https://cloudron.io/appstore.html#com.hastebin.cloudronapp + +## Proxy configuration +source: http://www.ctrl-alt-del.cc/2014/11/haste-server-base-url-hackpatch.html + +### HAProxy + +``` + frontend shared-http-frontend + mode http + bind 0.0.0.0:80 + default_backend main_website + # ACLs for request routing + acl acl_haste path_beg /haste/ + use_backend haste_backend if acl_haste + + backend haste_backend + server haste 127.0.0.1:7777 + reqirep ^([^\ :]*)\ /haste/(.*) \1\ /\2 + + backend main_website + server main_web 127.0.0.1:8000 + +``` + +### Nginx + +``` + location ^~ /haste/ { + proxy_buffering off; + rewrite /haste/(.*) /$1 break; + proxy_pass http://127.0.0.1:7777/; + proxy_redirect default; + } +``` + +### Lighttpd +``` + server.modules += ( "mod_rewrite", "mod_proxy" ) + + # Matching Proxy + # + $HTTP["url"] =~ "(^/haste/)" { + proxy.server = ( "" => ( + "servername:80" => # name + ( "host" => "127.0.0.1", + "port" => 82 + ) + ) + ) + } + + # URL Rewriting Proxy + # + $SERVER["socket"] == "127.0.0.1:82" { + url.rewrite-once = ( "^/haste/(.*)$" => "/$1" ) + proxy.server = ( "" => ( + "servername:82" => # name + ( "host" => "127.0.0.1", # Set the IP address of servername + "port" => 7777 + ) + ) + ) + } +``` + +### Apache + +First we need to enable mod_proxy and mod_proxy_http: +``` + a2enmod proxy + a2enmod proxy_http +``` +Then add to the vhost configuration file: +``` + ProxyPass /haste/ http://127.0.0.1:7777/ + ProxyPassReverse /haste/ http://127.0.0.1:7777/ +``` +So that the full config looks like this + +``` + + ServerAdmin xxx@xxx.com + ServerName xxx.com + ServerAlias www.xxx.com + ProxyPass / http://127.0.0.1:7777/ + ProxyPassReverse / http://127.0.0.1:7777/ + ErrorLog log/log.log + + Order deny,allow + Allow from all + + +``` +This will also work + +``` + + ServerAdmin xxx@xxx.com + DocumentRoot /var/www/xxxhaste-server + ServerAlias xxx.com + ServerName www.xxx.com + ErrorLog logs/log.log + ProxyPreserveHost On + ProxyRequests Off + ProxyPass / http://localhost:7777/ + ProxyPassReverse / http://localhost:7777/ + + + +``` \ No newline at end of file