@@ -42,7 +42,23 @@ Create configuration file ``/opt/local/etc/haproxy/haproxy.cfg`` with the follow
42
42
bind *:443 ssl crt /Users/brodijak/ssl/chain.pem
43
43
bind *:6443 ssl crt /Users/brodijak/ssl/chain.pem
44
44
45
+ acl is_node req.fhdr(Host),map_str(/opt/local/etc/haproxy/node_domains.map) -m found
46
+ acl is_node_pass_through path_reg -i -f /opt/local/etc/haproxy/node_pass_through.patterns
47
+
48
+ http-request capture req.hdr(Host) len 128
49
+ http-request capture req.fhdr(Referer) len 128
50
+
45
51
http-response set-header x-haproxy-frontend local
52
+ http-request set-header x-forwarded-proto https if { ssl_fc }
53
+
54
+ option forwardfor
55
+
56
+ use_backend nginx if { path -m beg /.well-known/ } { dst_port 80 }
57
+ use_backend nginx if { path -m beg /.well-known/ } { dst_port 443 }
58
+ use_backend varnish if { path -m beg /.well-known/ } { dst_port 6080 }
59
+ use_backend varnish if { path -m beg /.well-known/ } { dst_port 6443 }
60
+
61
+ use_backend node if is_node !is_node_pass_through
46
62
47
63
use_backend nginx if { dst_port 80 }
48
64
use_backend nginx if { dst_port 443 }
@@ -51,16 +67,66 @@ Create configuration file ``/opt/local/etc/haproxy/haproxy.cfg`` with the follow
51
67
52
68
default_backend nginx
53
69
70
+ backend node
71
+ http-request set-dst-port req.fhdr(Host),map(/opt/local/etc/haproxy/node_ports.map)
72
+ http-response set-header x-haproxy-backend node
73
+ server node 127.0.0.1:0 maxconn 32
74
+
54
75
backend nginx
55
76
http-response set-header x-haproxy-backend nginx
56
- server nginx 127.0.0.1:8080 maxconn 32
77
+ server nginx 127.0.0.1:8080 maxconn 32
57
78
58
79
backend varnish
59
80
http-response set-header x-haproxy-backend varnish
60
- server varnish 127.0.0.1:6081 maxconn 32
81
+ server varnish 127.0.0.1:6081 maxconn 32
61
82
62
83
Make sure to adapt the paths to certificate chain file on your system.
63
84
85
+ Create domain map file ``/opt/local/etc/haproxy/node_domains.map `` with the following content:
86
+
87
+ .. code :: console
88
+
89
+ # Contains a list of domains handled by Node.js, mapped to a corresponding domain
90
+ # handled by Varnish/PHP:
91
+
92
+ node.pro.dev.php82.ez pro.dev.php82.ez
93
+ us.node.pro.dev.php82.ez us.pro.dev.php82.ez
94
+
95
+ Create port map file ``/opt/local/etc/haproxy/node_domains.map `` with the following content:
96
+
97
+ .. code :: console
98
+
99
+ # Contains a list of domains handled by Node.js, mapped to a corresponding port
100
+ # on which Node.js app is running:
101
+
102
+ node.pro.dev.php82.ez 3000
103
+ us.node.pro.dev.php82.ez 3000
104
+
105
+ Create file containing pass-through patterns ``/opt/local/etc/haproxy/node_pass_through.patterns ``
106
+ with the following content:
107
+
108
+ .. code :: console
109
+
110
+ # Contains regular expression patterns to match URLs that are found on Node.js domains,
111
+ # but should be handled by Varnish/PHP instead of Node.js (passed through to PHP)
112
+
113
+ # API endpoints
114
+ ^/(en/|fr/|de/|hr/)?(api|ngopenapi)
115
+
116
+ # Admin
117
+ ^/adminui
118
+
119
+ # Assets
120
+ ^/bundles
121
+ ^/assets
122
+
123
+ # Debug
124
+ ^/_wdt
125
+
126
+ # Sitemaps and robots.txt
127
+ ^/sitemap/.*
128
+ ^/robots.txt
129
+
64
130
3 Start
65
131
-------
66
132
0 commit comments