Skip to content

Commit 44c1f26

Browse files
committed
feat: support SSL and http base access authentication
1 parent 10f4af2 commit 44c1f26

File tree

5 files changed

+76
-16
lines changed

5 files changed

+76
-16
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ RUN sed -i 's#http://archive.ubuntu.com/#http://tw.archive.ubuntu.com/#' /etc/ap
55

66
# built-in packages
77
RUN apt-get update \
8-
&& apt-get install -y --no-install-recommends software-properties-common curl \
8+
&& apt-get install -y --no-install-recommends software-properties-common curl apache2-utils \
99
&& add-apt-repository ppa:fcwu-tw/apps \
1010
&& apt-get update \
1111
&& apt-get install -y --no-install-recommends --allow-unauthenticated \

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,21 @@ build:
77
docker build -t $(REPO):$(TAG) .
88

99
run:
10-
docker run -it --rm -p 6080:80 \
10+
docker run --rm \
11+
-p 6080:80 -p 6081:443 \
12+
-v ${PWD}:/src:ro \
13+
-e USER=doro -e PASSWORD=mypassword \
14+
-e ALSADEV=hw:2,0 \
15+
-e SSL_PORT=443 \
16+
-e HTTP_PASSWORD=mypassword \
17+
-v ${PWD}/ssl:/etc/nginx/ssl \
1118
--name ubuntu-desktop-lxde-test \
1219
$(REPO):$(TAG)
1320

1421
shell:
1522
docker exec -it ubuntu-desktop-lxde-test bash
23+
24+
gen-ssl:
25+
mkdir -p ssl
26+
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
27+
-keyout ssl/nginx.key -out ssl/nginx.crt

README.md

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,52 +10,76 @@ Docker image to provide HTML5 VNC interface to access Ubuntu 16.04 LXDE desktop
1010
Quick Start
1111
-------------------------
1212

13-
Run the docker image and open port `6080`
13+
Run the docker container and access with port `6080`
1414

1515
```
16-
docker run -it --rm -p 6080:80 dorowu/ubuntu-desktop-lxde-vnc
16+
docker run -p 6080:80 dorowu/ubuntu-desktop-lxde-vnc
1717
```
1818

1919
Browse http://127.0.0.1:6080/
2020

2121
<img src="https://raw.github.com/fcwu/docker-ubuntu-vnc-desktop/master/screenshots/lxde.png?v1" width=700/>
2222

2323

24-
Connect with VNC Viewer and protect by VNC Password
24+
VNC Viewer
2525
------------------
2626

2727
Forward VNC service port 5900 to host by
2828

2929
```
30-
docker run -it --rm -p 6080:80 -p 5900:5900 dorowu/ubuntu-desktop-lxde-vnc
30+
docker run -p 6080:80 -p 5900:5900 dorowu/ubuntu-desktop-lxde-vnc
3131
```
3232

3333
Now, open the vnc viewer and connect to port 5900. If you would like to protect vnc service by password, set environment variable `VNC_PASSWORD`, for example
3434

3535
```
36-
docker run -it --rm -p 6080:80 -p 5900:5900 -e VNC_PASSWORD=mypassword dorowu/ubuntu-desktop-lxde-vnc
36+
docker run -p 6080:80 -p 5900:5900 -e VNC_PASSWORD=mypassword dorowu/ubuntu-desktop-lxde-vnc
3737
```
3838

3939
A prompt will ask password either in the browser or vnc viewer.
4040

41+
HTTP Base Authentication
42+
---------------------------
43+
44+
This image provides base access authentication of HTTP via `HTTP_PASSWORD`
45+
46+
```
47+
docker run -p 6080:80 -e HTTP_PASSWORD=mypassword dorowu/ubuntu-desktop-lxde-vnc
48+
```
49+
50+
SSL
51+
--------------------
52+
53+
To connect with SSL, generate self signed SSL certificate first if you don't have it
54+
55+
```
56+
mkdir -p ssl
57+
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout ssl/nginx.key -out ssl/nginx.crt
58+
```
59+
60+
Specify SSL port by `SSL_PORT`, certificate path to `/etc/nginx/ssl`, and forward it to 6081
61+
62+
```
63+
docker run -p 6081:443 -e SSL_PORT=443 -v ${PWD}/ssl:/etc/nginx/ssl dorowu/ubuntu-desktop-lxde-vnc
64+
```
4165

4266
Screen Resolution
4367
------------------
4468

4569
The Resolution of virtual desktop adapts browser window size when first connecting the server. You may choose a fixed resolution by passing `RESOLUTION` environment variable, for example
4670

4771
```
48-
docker run -it --rm -p 6080:80 -e RESOLUTION=1920x1080 dorowu/ubuntu-desktop-lxde-vnc
72+
docker run -p 6080:80 -e RESOLUTION=1920x1080 dorowu/ubuntu-desktop-lxde-vnc
4973
```
5074

5175

52-
Default User
53-
------------------
76+
Default Desktop User
77+
--------------------
5478

5579
The default user is `root`. You may change the user and password respectively by `USER` and `PASSWORD` environment variable, for example,
5680

5781
```
58-
docker run -it --rm -p 6080:80 -e USER=doro -e PASSWORD=password dorowu/ubuntu-desktop-lxde-vnc
82+
docker run -p 6080:80 -e USER=doro -e PASSWORD=password dorowu/ubuntu-desktop-lxde-vnc
5983
```
6084

6185
Troubleshooting and FAQ

image/etc/nginx/sites-enabled/default

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
server {
22
listen 80 default_server;
3-
#listen [::]:6080 default_server ipv6only=on;
3+
# listen [::]:80 default_server ipv6only=on;
4+
5+
#_SSL_PORT_#listen 443 ssl default_server;
6+
#_SSL_PORT_#listen [::]:443 ssl default_server ipv6only=on;
7+
#_SSL_PORT_#ssl_certificate /etc/nginx/ssl/nginx.crt;
8+
#_SSL_PORT_#ssl_certificate_key /etc/nginx/ssl/nginx.key;
9+
10+
#_HTTP_PASSWORD_#auth_basic "Private Property";
11+
#_HTTP_PASSWORD_#auth_basic_user_file /etc/nginx/.htpasswd;
412

513
root /usr/share/nginx/html;
614
index index.html index.htm;

image/startup.sh

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ fi
1515
USER=${USER:-root}
1616
HOME=/root
1717
if [ "$USER" != "root" ]; then
18+
echo "* enable custom user: $USER"
1819
useradd --create-home --shell /bin/bash --user-group --groups adm,sudo $USER
1920
if [ -z "$PASSWORD" ]; then
20-
echo set default password to \"ubuntu\"
21+
echo " set default password to \"ubuntu\""
2122
PASSWORD=ubuntu
2223
fi
2324
HOME=/home/$USER
@@ -32,10 +33,25 @@ mkdir -p $HOME/.config/pcmanfm/LXDE/
3233
ln -sf /usr/local/share/doro-lxde-wallpapers/desktop-items-0.conf $HOME/.config/pcmanfm/LXDE/
3334
chown -R $USER:$USER $HOME
3435

35-
# nginx
36-
sed -i 's#worker_processes .*#worker_processes 1;#' /etc/nginx/nginx.conf
36+
# nginx workers
37+
sed -i 's|worker_processes .*|worker_processes 1;|' /etc/nginx/nginx.conf
38+
39+
# nginx ssl
40+
if [ -n "$SSL_PORT" ] && [ -e "/etc/nginx/ssl/nginx.key" ]; then
41+
echo "* enable SSL"
42+
sed -i 's|#_SSL_PORT_#\(.*\)443\(.*\)|\1'$SSL_PORT'\2|' /etc/nginx/sites-enabled/default
43+
sed -i 's|#_SSL_PORT_#||' /etc/nginx/sites-enabled/default
44+
fi
45+
46+
# nginx http base authentication
47+
if [ -n "$HTTP_PASSWORD" ]; then
48+
echo "* enable HTTP base authentication"
49+
htpasswd -bc /etc/nginx/.htpasswd $USER $HTTP_PASSWORD
50+
sed -i 's|#_HTTP_PASSWORD_#||' /etc/nginx/sites-enabled/default
51+
fi
3752

3853
# clearup
3954
PASSWORD=
55+
HTTP_PASSWORD=
4056

41-
exec /bin/tini -- /usr/bin/supervisord -n
57+
exec /bin/tini -- /usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf

0 commit comments

Comments
 (0)