You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

347 lines
7.2 KiB

  1. #!/bin/bash
  2. exname=$(basename $0)
  3. prefix_cmd="
  4. . /etc/shlib
  5. include common
  6. include parse
  7. . ../lib/common
  8. "
  9. ##
  10. ## print_bytes
  11. ##
  12. # mock
  13. relation-get() {
  14. local key="$1"
  15. echo "$CFG" | shyaml get-value "$key" 2>/dev/null
  16. }
  17. export -f relation-get
  18. try "
  19. DOMAIN=www.example.com
  20. DOCKER_SITE_PATH=/var/www/\$DOMAIN
  21. apache_vhost_statement ,http,"
  22. noerror
  23. is out '<VirtualHost *:80>
  24. ServerAdmin contact@www.example.com
  25. ServerName www.example.com
  26. ServerSignature Off
  27. CustomLog /var/log/apache2/www.example.com_access.log combined
  28. ErrorLog /var/log/apache2/www.example.com_error.log
  29. ErrorLog syslog:local2
  30. ##
  31. ## Publish directory /var/www/www.example.com
  32. ##
  33. DocumentRoot /var/www/www.example.com
  34. <Directory />
  35. Options FollowSymLinks
  36. AllowOverride None
  37. </Directory>
  38. <Directory /var/www/www.example.com>
  39. Options Indexes FollowSymLinks MultiViews
  40. AllowOverride all
  41. Allow from all
  42. </Directory>
  43. ## Forbid any cache, this is only usefull on dev server.
  44. #Header set Cache-Control "no-cache"
  45. #Header set Access-Control-Allow-Origin "*"
  46. #Header set Access-Control-Allow-Methods "POST, GET, OPTIONS"
  47. #Header set Access-Control-Allow-Headers "origin, content-type, accept"
  48. </VirtualHost>' RTRIM
  49. ##
  50. ## Aliases
  51. ##
  52. try "
  53. DOMAIN=www.example.com
  54. DOCKER_SITE_PATH=/var/www/\$DOMAIN
  55. CFG='
  56. server-aliases:
  57. - toto
  58. '
  59. apache_vhost_statement ,http,"
  60. noerror
  61. is out reg 'ServerAlias toto'
  62. try "
  63. DOMAIN=www.example.com
  64. DOCKER_SITE_PATH=/var/www/\$DOMAIN
  65. CFG='
  66. server-aliases:
  67. - toto
  68. - titi
  69. '
  70. apache_vhost_statement ,http,"
  71. noerror
  72. is out reg 'ServerAlias toto'
  73. is out reg 'ServerAlias titi'
  74. ##
  75. ## Creds
  76. ##
  77. try "
  78. DOMAIN=www.example.com
  79. DOCKER_SITE_PATH=/var/www/\$DOMAIN
  80. CFG=''
  81. apache_vhost_statement ,http," "credentials allow all"
  82. noerror
  83. is out reg 'Allow from all'
  84. try "
  85. DOMAIN=www.example.com
  86. DOCKER_SITE_PATH=/var/www/\$DOMAIN
  87. CFG='
  88. creds:
  89. toto: xxx
  90. titi: yyy
  91. '
  92. apache_vhost_statement ,http," "credentials with basic auth user/pass"
  93. noerror
  94. is out reg 'AuthType basic'
  95. is out reg 'Require valid-user'
  96. ##
  97. ## proxy
  98. ##
  99. try "
  100. DOMAIN=www.example.com
  101. DOCKER_SITE_PATH=/var/www/\$DOMAIN
  102. CFG='
  103. target: popo:3333
  104. creds:
  105. toto: titi
  106. '
  107. proxy=yes apache_vhost_statement ,http," "proxy explicit target"
  108. noerror
  109. is out reg 'ProxyPass / http://popo:3333/'
  110. is out part '
  111. <Location / >
  112. AuthType basic
  113. AuthName "private"
  114. AuthUserFile /etc/apache2/sites-enabled/www.example.com.passwd
  115. Require valid-user
  116. ProxyPassReverse /
  117. </Location>
  118. '
  119. ##
  120. ## ssl
  121. ##
  122. try "
  123. DOMAIN=www.example.com
  124. DOCKER_SITE_PATH=/var/www/\$DOMAIN
  125. CFG='
  126. ssl: true
  127. target: popo:3333
  128. '
  129. SSL_PLUGIN_FUN=ssl_fallback proxy=yes apache_vhost_statement ,https," "ssl default generation (ssl-cert-snakeoil)"
  130. noerror
  131. is out reg 'VirtualHost \*:443'
  132. is out reg '<IfModule mod_ssl.c>'
  133. is out reg 'SSLEngine On'
  134. is out reg 'SSLProxyEngine On'
  135. is out reg 'ssl-cert-snakeoil'
  136. is out reg 'CustomLog /var/log/apache2/s-www.example.com_access.log combined'
  137. try "
  138. DOMAIN=www.example.com
  139. DOCKER_SITE_PATH=/var/www/\$DOMAIN
  140. CFG='
  141. ssl:
  142. ca-cert: a
  143. key: b
  144. cert: c
  145. target: popo:3333
  146. '
  147. SSL_PLUGIN_FUN=ssl_fallback proxy=yes apache_vhost_statement ,https," "ssl providing keys inline"
  148. noerror
  149. is out reg 'SSLCertificateFile /etc/ssl/certs/www.example.com.pem'
  150. is out reg 'SSLCertificateKeyFile /etc/ssl/private/www.example.com.key'
  151. is out reg 'SSLCACertificateFile /etc/ssl/certs/www.example.com-ca.pem'
  152. ##
  153. ## CustomRules
  154. ##
  155. try "
  156. DOMAIN=www.example.com
  157. DOCKER_SITE_PATH=/var/www/\$DOMAIN
  158. CFG='
  159. ssl:
  160. ca-cert: a
  161. key: b
  162. cert: c
  163. apache-custom-rules: |
  164. RewriteEngine On
  165. RewriteCond %{QUERY_STRING} !skin=formanoo
  166. RewriteRule ^(/web/webclient/home.*)$ $1?skin=formanoo [L,QSA,R=302]
  167. target: popo:3333
  168. '
  169. SSL_PLUGIN_FUN=ssl_fallback proxy=yes apache_vhost_statement ,https," "custom rules"
  170. noerror
  171. is out reg 'RewriteEngine On'
  172. ##
  173. ## double def
  174. ##
  175. try "
  176. DOMAIN=www.example.com
  177. DOCKER_SITE_PATH=/var/www/\$DOMAIN
  178. CFG='
  179. ssl:
  180. ca-cert: a
  181. key: b
  182. cert: c
  183. apache-custom-rules: |
  184. RewriteEngine On
  185. RewriteCond %{QUERY_STRING} !skin=formanoo
  186. RewriteRule ^(/web/webclient/home.*)$ $1?skin=formanoo [L,QSA,R=302]
  187. target: popo:3333
  188. '
  189. SSL_PLUGIN_FUN=ssl_fallback proxy=yes apache_vhost_statement ,https,http," "both http and https"
  190. noerror
  191. is out '<VirtualHost *:80>
  192. ServerAdmin contact@www.example.com
  193. ServerName www.example.com
  194. ServerSignature Off
  195. CustomLog /var/log/apache2/www.example.com_access.log combined
  196. ErrorLog /var/log/apache2/www.example.com_error.log
  197. ErrorLog syslog:local2
  198. ##
  199. ## Custom rules
  200. ##
  201. RewriteEngine On
  202. RewriteCond %{QUERY_STRING} !skin=formanoo
  203. RewriteRule ^(/web/webclient/home.*)$ ?skin=formanoo [L,QSA,R=302]
  204. ##
  205. ## Proxy declaration towards popo:3333
  206. ##
  207. <IfModule mod_proxy.c>
  208. ProxyRequests Off
  209. <Proxy *>
  210. Order deny,allow
  211. Allow from all
  212. </Proxy>
  213. ProxyVia On
  214. ProxyPass / http://popo:3333/ retry=0
  215. <Location / >
  216. Allow from all
  217. ProxyPassReverse /
  218. </Location>
  219. </IfModule>
  220. RequestHeader set "X-Forwarded-Proto" "http"
  221. ## Fix IE problem (httpapache proxy dav error 408/409)
  222. SetEnv proxy-nokeepalive 1
  223. ## Forbid any cache, this is only usefull on dev server.
  224. #Header set Cache-Control "no-cache"
  225. #Header set Access-Control-Allow-Origin "*"
  226. #Header set Access-Control-Allow-Methods "POST, GET, OPTIONS"
  227. #Header set Access-Control-Allow-Headers "origin, content-type, accept"
  228. </VirtualHost>
  229. <IfModule mod_ssl.c>
  230. <VirtualHost *:443>
  231. ServerAdmin contact@www.example.com
  232. ServerName www.example.com
  233. ServerSignature Off
  234. CustomLog /var/log/apache2/s-www.example.com_access.log combined
  235. ErrorLog /var/log/apache2/s-www.example.com_error.log
  236. ErrorLog syslog:local2
  237. ##
  238. ## Custom rules
  239. ##
  240. RewriteEngine On
  241. RewriteCond %{QUERY_STRING} !skin=formanoo
  242. RewriteRule ^(/web/webclient/home.*)$ ?skin=formanoo [L,QSA,R=302]
  243. ##
  244. ## Proxy declaration towards popo:3333
  245. ##
  246. <IfModule mod_proxy.c>
  247. ProxyRequests Off
  248. <Proxy *>
  249. Order deny,allow
  250. Allow from all
  251. </Proxy>
  252. ProxyVia On
  253. ProxyPass / http://popo:3333/ retry=0
  254. <Location / >
  255. Allow from all
  256. ProxyPassReverse /
  257. </Location>
  258. SSLProxyEngine On
  259. </IfModule>
  260. RequestHeader set "X-Forwarded-Proto" "https"
  261. ## Fix IE problem (httpapache proxy dav error 408/409)
  262. SetEnv proxy-nokeepalive 1
  263. ## Forbid any cache, this is only usefull on dev server.
  264. #Header set Cache-Control "no-cache"
  265. #Header set Access-Control-Allow-Origin "*"
  266. #Header set Access-Control-Allow-Methods "POST, GET, OPTIONS"
  267. #Header set Access-Control-Allow-Headers "origin, content-type, accept"
  268. ##
  269. ## SSL Configuration
  270. ##
  271. SSLEngine On
  272. SSLCertificateFile /etc/ssl/certs/www.example.com.pem
  273. SSLCertificateKeyFile /etc/ssl/private/www.example.com.key
  274. SSLCACertificateFile /etc/ssl/certs/www.example.com-ca.pem
  275. SSLVerifyClient None
  276. </VirtualHost>
  277. </IfModule>' RTRIM