Docs
Search…
Secure (HTTPS) Access to Antman

InstantSSL™: Easy https to antMan

With the introduction of antMan 0.9.1 we can set a subdomain to access antMan via https://<subdomain>.antsle.us
First we want to set the subdomain in antHill. We will assume you have activated your Antsle in antHill, if you have not take a look at the release annoucement for 0.9.0. Once you login to antHill you should see your Antsle in your dashboard.
The under the subdomain column click "Get one!". You can then set the subdomain you want for this Antsle as long as its available. Lets say we set the subdomain to aster. After you submit the configuration you will be able to connect to antMan via https://aster.antsle.us!
With InstantSSL configured, you can now securely access your antlets--just like antMan--via https. You can reach an https server on an antlet with the antlet name and antsle.us subdomain.
e.g. if I have an antlet named 'webserver', you can securely access your antlet via https://webserver.aster.antsle.us

Manual https to antMan

    1.
    Obtain your domain name, SSL certificate files
    2.
    Place the certificate files in the certs directory
    3.
    Create a virtualhosts .conf file
    4.
    Restart nginx
Note: If using a self-signed certificate, as I will in this example, your browser will show warnings because the certificate has not been signed by a trusted CA. Note: Replace antman.mydomain.com with your domain in the example configuration.
First lets create a new directory to store our certificate files
1
mkdir -p /etc/ssl/certs/mycerts
Copied!
Then copy your certificate files to the mycerts directory with sftp (Filezilla) or scp. For this example I will create a self-signed certificate. You can skip creating the self-signed certificate if you already have your certificate.
1
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/certs/mycerts/antman-selfsigned.key -out /etc/ssl/certs/mycerts/antman-selfsigned.crt
Copied!
You will be prompted with several questions. Enter your domain name when prompted for "Common Name"
1
Common Name (e.g. server FQDN or YOUR name) []: antman.mydomain.com
Copied!
Create and edit a new nginx virtualhosts configuration file. The .conf extension is required.
1
nano /etc/nginx/virtualhosts/ssl.antman.mydomain.com.conf
Copied!
Paste the following content into the file. Replace antman.mydomain.com with your domain name on lines 9, 10 and 18. Replace the certificate path/file names if different on lines 16, 17, 46, 47, 92 and 93.
1
map $http_upgrade $connection_upgrade {
2
default upgrade;
3
'' close;
4
}
5
6
# redirect http request
7
server {
8
listen 80;
9
server_name antman.mydomain.com;
10
rewrite ^ https://antman.mydomain.com$request_uri redirect;
11
}
12
13
server {
14
listen 443 ssl;
15
ssl_certificate /etc/ssl/certs/mycerts/antman-selfsigned.crt;
16
ssl_certificate_key /etc/ssl/certs/mycerts/antman-selfsigned.key;
17
server_name antman.mydomain.com;
18
root /var/www;
19
20
location / {
21
proxy_read_timeout 300;
22
proxy_connect_timeout 300;
23
proxy_redirect off;
24
25
proxy_set_header Host $host;
26
proxy_set_header X-Real-IP $remote_addr;
27
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
28
proxy_set_header X-Forwarded-Proto $scheme;
29
proxy_set_header X-Forwarded-Protocol $scheme;
30
proxy_set_header X-Forwarded-Ssl off;
31
proxy_set_header X-Url-Scheme $scheme;
32
proxy_set_header X-Frame-Options SAMEORIGIN;
33
34
# Forward WebSocket.
35
proxy_http_version 1.1;
36
proxy_set_header Upgrade $http_upgrade;
37
proxy_set_header Connection $connection_upgrade;
38
39
proxy_pass http://127.0.0.1:3000;
40
}
41
}
42
43
server {
44
listen 6843 ssl;
45
ssl_certificate /etc/ssl/certs/mycerts/antman-selfsigned.crt;
46
ssl_certificate_key /etc/ssl/certs/mycerts/antman-selfsigned.key;
47
root /var/www;
48
49
location / {
50
proxy_read_timeout 300;
51
proxy_connect_timeout 300;
52
proxy_redirect off;
53
54
proxy_set_header Host $host;
55
proxy_set_header X-Real-IP $remote_addr;
56
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
57
proxy_set_header X-Forwarded-Proto $scheme;
58
proxy_set_header X-Forwarded-Protocol $scheme;
59
proxy_set_header X-Forwarded-Ssl off;
60
proxy_set_header X-Url-Scheme $scheme;
61
proxy_set_header X-Frame-Options SAMEORIGIN;
62
63
# Forward WebSocket.
64
proxy_http_version 1.1;
65
proxy_set_header Upgrade $http_upgrade;
66
proxy_set_header Connection $connection_upgrade;
67
68
proxy_pass http://127.0.0.1:6822;
69
}
70
}
71
72
map $server_port $vnc_port {
73
~67(?<id>\d\d) 69$id;
74
}
75
server {
76
# These 'listen' lines are for the vncConsoles in antMan. If you will have more
77
# than 10 kvm antlets you can add more. Just increment the port number for each
78
# additional line.
79
listen 6700 ssl;
80
listen 6701 ssl;
81
listen 6702 ssl;
82
listen 6703 ssl;
83
listen 6704 ssl;
84
listen 6705 ssl;
85
listen 6706 ssl;
86
listen 6707 ssl;
87
listen 6708 ssl;
88
listen 6709 ssl;
89
listen 6710 ssl;
90
91
ssl_certificate /etc/ssl/certs/mycerts/antman-selfsigned.crt;
92
ssl_certificate_key /etc/ssl/certs/mycerts/antman-selfsigned.key;
93
root /var/www;
94
95
location / {
96
proxy_read_timeout 300;
97
proxy_connect_timeout 300;
98
proxy_redirect off;
99
100
proxy_set_header Host $host;
101
proxy_set_header X-Real-IP $remote_addr;
102
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
103
proxy_set_header X-Forwarded-Proto $scheme;
104
proxy_set_header X-Forwarded-Protocol $scheme;
105
proxy_set_header X-Forwarded-Ssl off;
106
proxy_set_header X-Url-Scheme $scheme;
107
proxy_set_header X-Frame-Options SAMEORIGIN;
108
109
# Forward WebSocket.
110
proxy_http_version 1.1;
111
proxy_set_header Upgrade $http_upgrade;
112
proxy_set_header Connection $connection_upgrade;
113
114
proxy_pass http://127.0.0.1:$vnc_port;
115
}
116
}
Copied!
Restart the nginx service
1
service nginx restart
Copied!
If working on the same local network as the antsle, the domain name must resolve to the private IP of the antsle. If accessing remotely from the public internet, the domain name must resolve to your gateway/router public IP address and the router must forward port 443 to the antsle's private IP address.

SSH Reverse Tunnel to antMan

SSH can be used to create a 'reverse tunnel' to antMan. The nice thing about this is the only configuration required is to create the port forwarding rule in the router. No additional nginx configuration or ssl certificates are required.
For example:
    router public IP: 2.2.2.2
    Antsle private IP: 192.168.1.3
    router is forwarding port 22 to the Antsle's private IP 192.168.1.3 port 22
We can run the following command from a remote location
1
ssh [email protected] -L 3333:localhost:3000
Copied!
The command maps a local port (3333 in this case) to the remote port (3000) via an ssh tunnel - antMan is listening on port 3000. Now you can enter the following url in your browser to open the remote antMan
1
http://localhost:3333
Copied!
Using port 3333 is just an arbitrary choice. You can uses different local port numbers to connect to different antsle's e.g. 3333 for the San Diego Antsle and 4444 for the Dallas Antsle.
In the first example the standard ssh port is used (22). But you could forward a different port on the public side of your router. In this next example we will use port 44761 on the public side of the router.
    router is forwarding port 44761 to the Antsle's private IP 192.168.1.3 port 22
For this use the '-p' option to designate the target ssh port.
1
ssh -p 44761 [email protected] -L 3333:localhost:3000
Copied!
The url used in your browser to open antMan is the same as the first example.
To be able to open remote kvm antlet vncConsoles via antMan add these port mappings to the ssh command
1
ssh -p 44761 [email protected] -L 3333:localhost:3000 -L 6900:localhost:6900 -L 6901:localhost:6901 -L 6902:localhost:6902
Copied!
You can add as many '-L' mappings as you like. The first kvm antlet started will use port 6900 for its console. The second kvm antlet started will use port 6901... and so on.

Manual https to antlets

To set up an ssl certificate for an antlet we have a couple of options
    Install the certificate in the antlet
    Use nginx proxy to handle the certificate
The first option requires the antlet to have a bridged NIC and be addressed directly. The traffic for each antlet/webserver would require a unique public IP address or use a unique port number for the router to direct the traffic to the correct antlet IP address. Here the certificate files are installed and handled by the antlet
The second option allows nginx to connect to the proper antlet based on the URL in the header of the request. This is desireable because you can forward traffic (at the router) for multiple sites to one IP address, the private IP address of the Antsle. The certificate files are installed and handled by nginx on the edgeLinux OS.
First create a directory for your certificate files on the edgeLinux OS.
1
mkdir -p /etc/ssl/certs/mycerts
Copied!
Use SCP or SFTP to copy your certificate files to this directory.
Create and edit a new nginx virtualhosts configuration file for your domain name. Replace example.com with your domain name.
1
nano /etc/nginx/virtualhosts/ssl.example.com.conf
Copied!
Paste the following content into the file and replace 'example.com' with your domain name.
1
# SSL to antlet
2
3
# If you want to use your domain example.com in HTTPS mode (with SSL),
4
# rename this file to ssl.example.com.conf (from ssl.example.com.conf.HTTPS)
5
# Replace example.com with your domain name.
6
# Make sure you have your SSL certificate installed properly.
7
# The certificate files are not required to be in the directories presented here, but
8
# the path must be the correct path to your certificate files.
9
10
# The webserver on your antlet will listen on port 80 (http).
11
# Nginx on edgeLinux handles SSL (https).
12
13
# Redirect http://www.example.com to https://example.com
14
# If your domain name does include 'www' then remove this server block and use the full
15
# domain name in the last server block.
16
server {
17
listen 80;
18
server_name www.example.com;
19
rewrite ^ https://example.com$request_uri redirect;
20
}
21
22
# Redirect http://... to https://...
23
server {
24
listen 80;
25
server_name example.com;
26
rewrite ^ https://example.com$request_uri redirect;
27
}
28
29
# Redirect https://www... to https://example.com
30
# If your domain name does include 'www' then remove this server block and use the full
31
# domain name in the last server block.
32
server {
33
listen 443 ssl;
34
ssl_certificate /etc/ssl/certs/mycerts/example.com.crt;
35
ssl_certificate_key /etc/ssl/certs/mycerts/example.com.key;
36
server_name www.example.com;
37
rewrite ^ $scheme://example.com$request_uri redirect;
38
}
39
40
# Think of the word 'example' in 'upstream example' as a variable name which is
41
# used in other server blocks. This name must be unique among all your .conf
42
# files. It is used in the two 'proxy_pass' lines in the next server block.
43
# If you change the upstream variable name then be sure to update the proxy_pass
44
# lines also.
45
upstream example {
46
# Enter the IP address and port number of your antlet handling this domain
47
server 10.1.1.10:80;
48
}
49
50
server {
51
listen 443 ssl;
52
ssl_certificate /etc/ssl/certs/mycerts/example.com.crt;
53
ssl_certificate_key /etc/ssl/certs/mycerts/example.com.key;
54
server_name example.com;
55
root /var/www;
56
57
location / {
58
proxy_read_timeout 300;
59
proxy_connect_timeout 300;
60
proxy_redirect off;
61
proxy_buffers 4 256k;
62
proxy_buffer_size 128k;
63
proxy_busy_buffers_size 256k;
64
65
proxy_set_header Host $host;
66
proxy_set_header X-Real-IP $remote_addr;
67
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
68
proxy_set_header X-Forwarded-Proto $scheme;
69
proxy_set_header X-Forwarded-Protocol $scheme;
70
proxy_set_header X-Forwarded-Ssl off;
71
proxy_set_header X-Url-Scheme $scheme;
72
proxy_set_header X-Frame-Options SAMEORIGIN;
73
74
proxy_pass http://example;
75
}
76
77
location ~* \.(jpg|jpeg|png|gif|ico|css|js|pdf|woff|woff2)(\?.*)?$ {
78
expires 365d;
79
add_header Cache-Control "public, max-age=315360000";
80
access_log off;
81
82
proxy_read_timeout 300;
83
proxy_connect_timeout 300;
84
proxy_redirect off;
85
proxy_buffers 8 24k;
86
proxy_buffer_size 2k;
87
88
proxy_set_header Host $host;
89
proxy_set_header X-Real-IP $remote_addr;
90
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
91
proxy_set_header X-Forwarded-Proto $scheme;
92
proxy_set_header X-Forwarded-Protocol $scheme;
93
proxy_set_header X-Forwarded-Ssl off;
94
proxy_set_header X-Url-Scheme $scheme;
95
proxy_set_header X-Frame-Options SAMEORIGIN;
96
97
proxy_pass http://example;
98
99
}
100
}
Copied!
In the 'upstream' block replace the word 'example' with your domain name and enter the server IP address. For example if the domain name is 'antsle.com' and the antlet address is 10.1.1.32 and listening on port 8080, then the upstream block would look like this:
1
upstream antsle {
2
# Enter the IP address and port number of your antlet handling this domain
3
server 10.1.1.32:8080;
4
}
Copied!
Replace the two occurrences of 'proxy_pass http://example;' with the upstream name on lines 74 and 102
1
proxy_pass http://antsle
Copied!
Restart the nginx service
1
service nginx restart
Copied!
Last modified 2mo ago