Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
haproxy/doc/network-namespaces.txt at master · DaChengTechnology/haproxy · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
DaChengTechnology
haproxy
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
haproxy
/
doc
/
network-namespaces.txt
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
106 lines (80 loc) · 3.46 KB
master
Breadcrumbs
haproxy
/
doc
/
network-namespaces.txt
Copy path
Top
File metadata and controls
Code
Blame
106 lines (80 loc) · 3.46 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
Linux network namespace support for HAProxy
===========================================
HAProxy supports proxying between Linux network namespaces. This
feature can be used, for example, in a multi-tenant networking
environment to proxy between different networks. HAProxy can also act
as a front-end proxy for non namespace-aware services.
The proxy protocol has been extended to support transferring the
namespace information, so the originating namespace information can be
kept. This is useful when chaining multiple proxies and services.
To enable Linux namespace support, compile HAProxy with the `USE_NS=1`
make option.
## Setting up namespaces on Linux
To create network namespaces, use the 'ip netns' command. See the
manual page ip-netns(8) for details.
Make sure that the file descriptors representing the network namespace
are located under `/var/run/netns`.
For example, you can create a network namespace and assign one of the
networking interfaces to the new namespace:
```
$ ip netns add netns1
$ ip link set eth7 netns netns1
```
## Listing namespaces in the configuration file
HAProxy uses namespaces explicitly listed in its configuration file.
If you are not using namespace information received through the proxy
protocol, this usually means that you must specify namespaces for
listeners and servers in the configuration file with the 'namespace'
keyword.
However, if you're using the namespace information received through
the proxy protocol to determine the namespace of servers (see
'namespace * below'), you have to explicitly list all allowed
namespaces in the namespace_list section of your configuration file:
```
namespace_list
namespace netns1
namespace netns2
```
## Namespace information flow
The haproxy process always runs in the namespace it was started on.
This is the default namespace.
The bind addresses of listeners can have their namespace specified in
the configuration file. Unless specified, sockets associated with
listener bind addresses are created in the default namespace. For
example, this creates a listener in the netns2 namespace:
```
frontend f_example
bind 192.168.1.1:80 namespace netns2
default_backend http
```
Each client connection is associated with its source namespace. By
default, this is the namespace of the bind socket it arrived on, but
can be overridden by information received through the proxy protocol.
Proxy protocol v2 supports transferring namespace information, so if
it is enabled for the listener, it can override the associated
namespace of the connection.
Servers can have their namespaces specified in the configuration file
with the 'namespace' keyword:
```
backend b_example
server s1 192.168.1.100:80 namespace netns2
```
If no namespace is set for a server, it is assumed that it is in the
default namespace. When specified, outbound sockets to the server are
created in the network namespace configured. To create the outbound
(server) connection in the namespace associated with the client, use
the '*' namespace. This is especially useful when using the
destination address and namespace received from the proxy protocol.
```
frontend f_example
bind 192.168.1.1:9990 accept-proxy
default_backend b_example
backend b_example
mode tcp
source 0.0.0.0 usesrc clientip
server snodes * namespace *
```
If HAProxy is configured to send proxy protocol v2 headers to the
server, the outgoing header will always contain the namespace
associated with the client connection, not the namespace configured
for the server.
You can’t perform that action at this time.