Skip to content

Commit

Permalink
Fixup Apache 2.2 proxy settings
Browse files Browse the repository at this point in the history
  • Loading branch information
cytopia committed Dec 27, 2022
1 parent df0d580 commit b36fc9a
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions etc/templates/apache22.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,23 @@
# __PHP_PORT__
#

###
### Notes about Apache
###

#
# 1. Each same directive is checked in order of definition (last one wins)
# 2. Directives are ordered: Directory, DirectoryMatch, Files, and finally Location (last one wins)
# * Last match always takes precedence
#
# Exception: Directories, where shortest path is matched first
# Exception: ProxyPass and Alias first match and then stops

###
### Basic vHost skeleton
###
### Note: Reverse Proxy section must be last for Apache 2.2
###
vhost: |
<VirtualHost __DEFAULT_VHOST__:__PORT__>
ServerName __VHOST_NAME__
Expand All @@ -57,10 +70,10 @@ vhost: |
__PHP_FPM__
__ALIASES__
__DENIES__
__VHOST_RPROXY__
__SERVER_STATUS__
# Custom directives
__CUSTOM__
__VHOST_RPROXY__
</VirtualHost>
###
Expand All @@ -86,28 +99,40 @@ vhost_type:
# Reverse Proxy (-r http(s)://ADDR:PORT)
rproxy: |
# Define Reverse Proxy
# ProxyRequests: Disable "Forward Proxy"
# ProxyPreserveHost: Pass "Host" header to remote
# ProxyAddHeaders: Add "X-Forward-*" headers
# ProxyVia: Add "Via" header
ProxyRequests Off
ProxyPreserveHost On
ProxyPass __LOCATION__ __PROXY_PROTO__://__PROXY_ADDR__:__PROXY_PORT__/ retry=0
ProxyPassReverse __LOCATION__ __PROXY_PROTO__://__PROXY_ADDR__:__PROXY_PORT__/
ProxyAddHeaders On
ProxyVia On
<Location __LOCATION__>
# Reverse Proxy
ProxyPass __PROXY_PROTO__://__PROXY_ADDR__:__PROXY_PORT__/ retry=0
ProxyPassReverse __PROXY_PROTO__://__PROXY_ADDR__:__PROXY_PORT__/
</Location>
# Reverse Proxy with websocket support (-r ws(s)://ADDR:PORT)
rproxy_ws: |
# Define Reverse Proxy with Websock support
# ProxyRequests: Disable "Forward Proxy"
# ProxyPreserveHost: Pass "Host" header to remote
# ProxyAddHeaders: Add "X-Forward-*" headers
# ProxyVia: Add "Via" header
ProxyRequests Off
ProxyPreserveHost On
<location __LOCATION__>
ProxyAddHeaders On
ProxyVia On
<Location __LOCATION__>
# Websocket Rewrite Settings
RewriteEngine On
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteRule ^/?(.*)$ __WS_PROTO__://__PROXY_ADDR__:__PROXY_PORT__/$1 [P,L]
# Reverse Proxy Settings
# Reverse Proxy
ProxyPass __PROXY_PROTO__://__PROXY_ADDR__:__PROXY_PORT__/ retry=0
ProxyPassReverse __PROXY_PROTO__://__PROXY_ADDR__:__PROXY_PORT__/
</location>
</Location>
###
Expand Down Expand Up @@ -147,10 +172,10 @@ features:
deny: |
# Deny Definition
<FilesMatch "__REGEX__">
<LocationMatch "__REGEX__">
Order allow,deny
Deny from all
</FilesMatch>
</LocationMatch>
server_status: |
# Status Page
Expand Down

0 comments on commit b36fc9a

Please sign in to comment.