Skip to content

Commit

Permalink
Added HAProxy configuration language (#4303)
Browse files Browse the repository at this point in the history
* Added HAProxy configuration language

* HAProxy - Removing hapee-lb.cfg as a filetype because it does not have much usage in the wild.

* Removing hapee-lb.cfg as a sample.

* HAProxy - Added config values that are more common.

* Adding more sample haproxy.cfg files.
  • Loading branch information
NickMRamirez authored and lildude committed Nov 7, 2018
1 parent 21005b3 commit 5371f7b
Show file tree
Hide file tree
Showing 11 changed files with 228 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@
[submodule "vendor/grammars/atom-language-clean"]
path = vendor/grammars/atom-language-clean
url = https://github.com/timjs/atom-language-clean.git
[submodule "vendor/grammars/atom-language-haproxy"]
path = vendor/grammars/atom-language-haproxy
url = https://github.com/abulimov/atom-language-haproxy
[submodule "vendor/grammars/atom-language-julia"]
path = vendor/grammars/atom-language-julia
url = https://github.com/JuliaEditorSupport/atom-language-julia
Expand Down
2 changes: 2 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ vendor/grammars/atom-language-1c-bsl:
vendor/grammars/atom-language-clean:
- source.clean
- text.restructuredtext.clean
vendor/grammars/atom-language-haproxy:
- source.haproxy-config
vendor/grammars/atom-language-julia:
- source.julia
- source.julia.console
Expand Down
9 changes: 9 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,15 @@ Groovy Server Pages:
codemirror_mode: htmlembedded
codemirror_mime_type: application/x-jsp
language_id: 143
HAProxy:
type: data
extensions:
- ".cfg"
filenames:
- haproxy.cfg
tm_scope: source.haproxy-config
ace_mode: text
language_id: 366607477
HCL:
type: programming
extensions:
Expand Down
57 changes: 57 additions & 0 deletions samples/HAProxy/haproxy.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# HAProxy configuration showing choosing a different backend for static files
global
maxconn 50000
log /dev/log local0
log /dev/log local1 notice
user haproxy
group haproxy
stats socket /run/haproxy/admin.sock user haproxy group haproxy mode 660 level admin
nbproc 1
nbthread 4
cpu-map auto:1/1-4 0-3
ssl-default-bind-ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets

defaults
timeout connect 5s
timeout client 5s
timeout server 5s
log global
mode http
option httplog
option dontlognull
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http

frontend public
bind 10.0.0.3:80
bind 10.0.0.3:443 ssl crt /etc/ssl/certs/mysite.pem
redirect scheme https if !{ ssl_fc }
acl static_files path_end .gif .png .jpg .css .js .svg .ttf .woff .woff2
use_backend nginx if static_files
default_backend nodejs

backend nodejs
balance roundrobin
cookie PHPSESSID prefix nocache
option httpchk HEAD /
default-server check maxconn 20
server server1 10.0.1.3:80 cookie server1
server server2 10.0.1.4:80 cookie server2

backend nginx
balance roundrobin
option httpchk HEAD /
server server1 10.0.1.5:80 check
server server2 10.0.1.6:80 check

listen admin
bind 0.0.0.0:8404
stats enable
stats uri /monitor
stats refresh 5
52 changes: 52 additions & 0 deletions samples/HAProxy/haproxy2.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# HAProxy configuration showing using Basic Auth on Stats page
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
ssl-default-bind-ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
ssl-default-bind-options no-sslv3
description HAProxy Statistics Page

defaults
log global
timeout connect 5000
timeout client 50000
timeout server 50000
mode http
option httplog
option dontlognull
balance roundrobin
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http

frontend fe_main
bind :80
bind :443 ssl crt mysite.pem
http-request redirect scheme https unless ssl_fc
default_backend webservers

backend webservers
server web1 192.168.0.3:80 check maxconn 20
server web2 192.168.0.4:80 check maxconn 20
server web3 192.168.0.5:80 check maxconn 20
server web4 192.168.0.6:80 check maxconn 20

listen stats
bind :9999 ssl crt mycert.pem
stats enable
stats uri /report
stats refresh 30s
stats auth admin:password
stats show-desc
http-request deny unless { src 192.168.50.0/24 }
36 changes: 36 additions & 0 deletions samples/HAProxy/haproxy3.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# HAProxy configuration showing load balancing TCP
global
log 192.168.50.2:514 local0 info
chroot /var/lib/haproxy
user haproxy
group haproxy

defaults
log global
mode tcp
balance leastconn
option tcplog
timeout connect 5s
timeout client 5m
timeout server 5m

frontend fe_mysql
bind *:3306
default_backend be_mysql

backend be_mysql
stick-table type ip size 1m expire 1h
stick match src
stick store-request src
log-tag mysql
server db1 192.168.50.10:3306 check slowstart 60s weight 1
server db2 192.168.50.11:3306 check slowstart 60s weight 3
server db3 192.168.50.12:3306 check slowstart 60s backup
server db4 192.168.50.13:3306 check slowstart 60s backup

listen stats
bind :9999 ssl crt /etc/ssl/certs/mycert.pem
stats enable
stats uri /report
stats refresh 30s
http-request deny unless { src 192.168.50.0/24 }
35 changes: 35 additions & 0 deletions samples/HAProxy/haproxy4.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# HAProxy configuration showing redirecting to different backends
global
log 192.168.50.2:514 local0
chroot /var/lib/haproxy
user haproxy
group haproxy
ssl-default-bind-ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets

defaults
log global
option httplog
timeout connect 5s
timeout client 1m
timeout server 1m

frontend mywebsite
bind :80
balance roundrobin
mode http
acl apipath path_beg /api/
acl apihost req.hdr(Host) -i -m dom api.mywebsite.com
redirect prefix http://api.mywebsite.com if apipath
use_backend apiservers if apihost
default_backend webservers

backend webservers
option httpchk HEAD /health
server web1 192.168.0.3:80 check maxconn 20
server web2 192.168.0.4:80 check maxconn 20

backend apiservers
option httpchk HEAD /health
server api1 192.168.0.10:80 check maxconn 20
server api2 192.168.0.11:80 check maxconn 20
6 changes: 6 additions & 0 deletions samples/INI/ms.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
title=Mindstorms
isbn=0465046290
author=Seymour Papert
pubmonth=198001
subject=children computers powerful ideas LOGO education
url=http://www.papert.org/
1 change: 1 addition & 0 deletions vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
- **Hack:** [textmate/php.tmbundle](https://github.com/textmate/php.tmbundle)
- **Haml:** [ezekg/language-haml](https://github.com/ezekg/language-haml)
- **Handlebars:** [daaain/Handlebars](https://github.com/daaain/Handlebars)
- **HAProxy:** [abulimov/atom-language-haproxy](https://github.com/abulimov/atom-language-haproxy)
- **Harbour:** [hernad/atom-language-harbour](https://github.com/hernad/atom-language-harbour)
- **Haskell:** [atom-haskell/language-haskell](https://github.com/atom-haskell/language-haskell)
- **Haxe:** [vshaxe/haxe-TmLanguage](https://github.com/vshaxe/haxe-TmLanguage)
Expand Down
1 change: 1 addition & 0 deletions vendor/grammars/atom-language-haproxy
Submodule atom-language-haproxy added at bc1e39
26 changes: 26 additions & 0 deletions vendor/licenses/grammar/atom-language-haproxy.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
type: grammar
name: atom-language-haproxy
version: bc1e39d523ed78f29284e3da13cb579dc0d29e30
license: mit
---
Copyright (c) 2016 Alexander Bulimov

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 comments on commit 5371f7b

Please sign in to comment.