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
6.9 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,"
  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,"
  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,"
  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. proxy=yes apache_vhost_statement ,https,"
  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. proxy=yes apache_vhost_statement ,https,"
  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. proxy=yes apache_vhost_statement ,https,"
  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. proxy=yes apache_vhost_statement ,https,http,"
  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. ## Proxy declaration towards popo:3333
  200. ##
  201. <IfModule mod_proxy.c>
  202. ProxyRequests Off
  203. <Proxy *>
  204. Order deny,allow
  205. Allow from all
  206. </Proxy>
  207. ProxyVia On
  208. ProxyPass / http://popo:3333/ retry=0
  209. <Location / >
  210. Allow from all
  211. ProxyPassReverse /
  212. </Location>
  213. </IfModule>
  214. RequestHeader set "X-Forwarded-Proto" "http"
  215. ## Fix IE problem (httpapache proxy dav error 408/409)
  216. SetEnv proxy-nokeepalive 1
  217. ## Forbid any cache, this is only usefull on dev server.
  218. #Header set Cache-Control "no-cache"
  219. #Header set Access-Control-Allow-Origin "*"
  220. #Header set Access-Control-Allow-Methods "POST, GET, OPTIONS"
  221. #Header set Access-Control-Allow-Headers "origin, content-type, accept"
  222. ##
  223. ## Custom rules
  224. ##
  225. RewriteEngine On
  226. RewriteCond %{QUERY_STRING} !skin=formanoo
  227. RewriteRule ^(/web/webclient/home.*)$ ?skin=formanoo [L,QSA,R=302]
  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. ## Proxy declaration towards popo:3333
  239. ##
  240. <IfModule mod_proxy.c>
  241. ProxyRequests Off
  242. <Proxy *>
  243. Order deny,allow
  244. Allow from all
  245. </Proxy>
  246. ProxyVia On
  247. ProxyPass / http://popo:3333/ retry=0
  248. <Location / >
  249. Allow from all
  250. ProxyPassReverse /
  251. </Location>
  252. SSLProxyEngine On
  253. </IfModule>
  254. RequestHeader set "X-Forwarded-Proto" "https"
  255. ## Fix IE problem (httpapache proxy dav error 408/409)
  256. SetEnv proxy-nokeepalive 1
  257. ## Forbid any cache, this is only usefull on dev server.
  258. #Header set Cache-Control "no-cache"
  259. #Header set Access-Control-Allow-Origin "*"
  260. #Header set Access-Control-Allow-Methods "POST, GET, OPTIONS"
  261. #Header set Access-Control-Allow-Headers "origin, content-type, accept"
  262. ##
  263. ## SSL Configuration
  264. ##
  265. SSLEngine On
  266. SSLCertificateFile /etc/ssl/certs/www.example.com.pem
  267. SSLCertificateKeyFile /etc/ssl/private/www.example.com.key
  268. SSLCACertificateFile /etc/ssl/certs/www.example.com-ca.pem
  269. SSLVerifyClient None
  270. ##
  271. ## Custom rules
  272. ##
  273. RewriteEngine On
  274. RewriteCond %{QUERY_STRING} !skin=formanoo
  275. RewriteRule ^(/web/webclient/home.*)$ ?skin=formanoo [L,QSA,R=302]
  276. </VirtualHost>
  277. </IfModule>' RTRIM