Skip to content

Commit 30816cc

Browse files
committed
First commit
0 parents  commit 30816cc

8 files changed

Lines changed: 284 additions & 0 deletions

File tree

.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ADDRESS=example@10.0.0.1
2+
DIRECTORY=/home/example
3+
SSH_PORT=22

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM nginx:latest
2+
3+
ENV SSH_PORT=22
4+
5+
WORKDIR /usr/share/nginx/html
6+
7+
RUN apt update && apt install -y \
8+
vim \
9+
sshfs \
10+
sshpass \
11+
procps
12+
13+
COPY fuse.conf /etc/fuse.conf
14+
COPY nginx.conf /etc/nginx/conf.d/default.conf
15+
COPY mime.types /etc/nginx/mime.types
16+
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint
17+
RUN chmod +x /usr/local/bin/docker-entrypoint
18+
19+
ENTRYPOINT ["docker-entrypoint"]
20+
CMD ["nginx", "-g", "daemon off;"]

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
### Requirement
2+
Ensure SSH Agent is Running on Host:
3+
Before you run your container, make sure the SSH agent is running on the host and your key is added.
4+
5+
```bash
6+
eval $(ssh-agent -s)
7+
ssh-add
8+
```
9+
10+
### Build
11+
```bash
12+
docker build -t te4g/mount-ssh .
13+
````
14+
15+
### Usage
16+
```bash
17+
docker run --rm --privileged \
18+
-v /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock \
19+
-e ADDRESS=$ADDRESS \
20+
-e DIRECTORY=$DIRECTORY \
21+
-e SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock \
22+
-p 9999:80 \
23+
te4g/mount-ssh
24+
```

docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
services:
2+
nginx:
3+
build: .
4+
volumes:
5+
- ./nginx.conf:/etc/nginx/conf.d/default.conf
6+
- ./mime.types:/etc/nginx/mime.types
7+
- ./fuse.conf:/etc/fuse.conf
8+
- /run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock
9+
privileged: true
10+
environment:
11+
- ADDRESS=${ADDRESS}
12+
- DIRECTORY=${DIRECTORY}
13+
- SSH_PORT=${SSH_PORT:-22}
14+
- SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock
15+
ports:
16+
- "9999:80"

docker-entrypoint.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
set -e
3+
4+
sshfs \
5+
-p "$SSH_PORT" \
6+
"$ADDRESS:$DIRECTORY" \
7+
/usr/share/nginx/html \
8+
-o allow_other \
9+
-o StrictHostKeyChecking=no
10+
11+
exec "$@"

fuse.conf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# The file /etc/fuse.conf allows for the following parameters:
2+
#
3+
# user_allow_other - Using the allow_other mount option works fine as root, in
4+
# order to have it work as user you need user_allow_other in /etc/fuse.conf as
5+
# well. (This option allows users to use the allow_other option.) You need
6+
# allow_other if you want users other than the owner to access a mounted fuse.
7+
# This option must appear on a line by itself. There is no value, just the
8+
# presence of the option.
9+
10+
user_allow_other
11+
12+
13+
# mount_max = n - this option sets the maximum number of mounts.
14+
# Currently (2014) it must be typed exactly as shown
15+
# (with a single space before and after the equals sign).
16+
17+
#mount_max = 1000

mime.types

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
types {
2+
text/html html htm shtml;
3+
text/css css;
4+
text/xml xml;
5+
image/gif gif;
6+
image/jpeg jpeg jpg;
7+
application/javascript js;
8+
application/atom+xml atom;
9+
application/rss+xml rss;
10+
11+
text/mathml mml;
12+
text/plain txt;
13+
text/vnd.sun.j2me.app-descriptor jad;
14+
text/vnd.wap.wml wml;
15+
text/x-component htc;
16+
17+
image/avif avif;
18+
image/png png;
19+
image/svg+xml svg svgz;
20+
image/tiff tif tiff;
21+
image/vnd.wap.wbmp wbmp;
22+
image/webp webp;
23+
image/x-icon ico;
24+
image/x-jng jng;
25+
image/x-ms-bmp bmp;
26+
27+
font/woff woff;
28+
font/woff2 woff2;
29+
30+
application/java-archive jar war ear;
31+
application/json json;
32+
application/mac-binhex40 hqx;
33+
application/msword doc;
34+
application/pdf pdf;
35+
application/postscript ps eps ai;
36+
application/rtf rtf;
37+
application/vnd.apple.mpegurl m3u8;
38+
application/vnd.google-earth.kml+xml kml;
39+
application/vnd.google-earth.kmz kmz;
40+
application/vnd.ms-excel xls;
41+
application/vnd.ms-fontobject eot;
42+
application/vnd.ms-powerpoint ppt;
43+
application/vnd.oasis.opendocument.graphics odg;
44+
application/vnd.oasis.opendocument.presentation odp;
45+
application/vnd.oasis.opendocument.spreadsheet ods;
46+
application/vnd.oasis.opendocument.text odt;
47+
application/vnd.openxmlformats-officedocument.presentationml.presentation
48+
pptx;
49+
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
50+
xlsx;
51+
application/vnd.openxmlformats-officedocument.wordprocessingml.document
52+
docx;
53+
application/vnd.wap.wmlc wmlc;
54+
application/wasm wasm;
55+
application/x-7z-compressed 7z;
56+
application/x-cocoa cco;
57+
application/x-java-archive-diff jardiff;
58+
application/x-java-jnlp-file jnlp;
59+
application/x-makeself run;
60+
application/x-perl pl pm;
61+
application/x-pilot prc pdb;
62+
application/x-rar-compressed rar;
63+
application/x-redhat-package-manager rpm;
64+
application/x-sea sea;
65+
application/x-shockwave-flash swf;
66+
application/x-stuffit sit;
67+
application/x-tcl tcl tk;
68+
application/x-x509-ca-cert der pem crt;
69+
application/x-xpinstall xpi;
70+
application/xhtml+xml xhtml;
71+
application/xspf+xml xspf;
72+
application/zip zip;
73+
74+
application/octet-stream bin exe dll;
75+
application/octet-stream deb;
76+
application/octet-stream dmg;
77+
application/octet-stream iso img;
78+
application/octet-stream msi msp msm;
79+
80+
audio/midi mid midi kar;
81+
audio/mpeg mp3;
82+
audio/ogg ogg;
83+
audio/x-m4a m4a;
84+
audio/x-realaudio ra;
85+
86+
video/3gpp 3gpp 3gp;
87+
video/mp2t ts;
88+
video/mp4 mp4;
89+
video/mpeg mpeg mpg;
90+
video/quicktime mov;
91+
video/webm mkv;
92+
video/x-flv flv;
93+
video/x-m4v m4v;
94+
video/x-mng mng;
95+
video/x-ms-asf asx asf;
96+
video/x-ms-wmv wmv;
97+
video/x-msvideo avi;
98+
}

nginx.conf

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
##
2+
# You should look at the following URL's in order to grasp a solid understanding
3+
# of Nginx configuration files in order to fully unleash the power of Nginx.
4+
# https://www.nginx.com/resources/wiki/start/
5+
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
6+
# https://wiki.debian.org/Nginx/DirectoryStructure
7+
#
8+
# In most cases, administrators will remove this file from sites-enabled/ and
9+
# leave it as reference inside of sites-available where it will continue to be
10+
# updated by the nginx packaging team.
11+
#
12+
# This file will automatically load configuration files provided by other
13+
# applications, such as Drupal or Wordpress. These applications will be made
14+
# available underneath a path with that package name, such as /drupal8.
15+
#
16+
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
17+
##
18+
19+
# Default server configuration
20+
#
21+
server {
22+
listen 80 default_server;
23+
listen [::]:80 default_server;
24+
25+
access_log /var/log/nginx/access.log main;
26+
27+
# SSL configuration
28+
#
29+
# listen 443 ssl default_server;
30+
# listen [::]:443 ssl default_server;
31+
#
32+
# Note: You should disable gzip for SSL traffic.
33+
# See: https://bugs.debian.org/773332
34+
#
35+
# Read up on ssl_ciphers to ensure a secure configuration.
36+
# See: https://bugs.debian.org/765782
37+
#
38+
# Self signed certs generated by the ssl-cert package
39+
# Don't use them in a production server!
40+
#
41+
# include snippets/snakeoil.conf;
42+
43+
root /usr/share/nginx/html;
44+
autoindex on;
45+
autoindex_format html;
46+
autoindex_localtime on;
47+
# Add index.php to the list if you are using PHP
48+
#index index.html index.htm index.nginx-debian.html;
49+
50+
server_name localhost;
51+
52+
location / {
53+
# First attempt to serve request as file, then
54+
# as directory, then fall back to displaying a 404.
55+
try_files $uri $uri/ =404;
56+
}
57+
58+
# pass PHP scripts to FastCGI server
59+
#
60+
#location ~ \.php$ {
61+
# include snippets/fastcgi-php.conf;
62+
#
63+
# # With php-fpm (or other unix sockets):
64+
# fastcgi_pass unix:/run/php/php7.4-fpm.sock;
65+
# # With php-cgi (or other tcp sockets):
66+
# fastcgi_pass 127.0.0.1:9000;
67+
#}
68+
69+
# deny access to .htaccess files, if Apache's document root
70+
# concurs with nginx's one
71+
#
72+
#location ~ /\.ht {
73+
# deny all;
74+
#}
75+
}
76+
77+
78+
# Virtual Host configuration for example.com
79+
#
80+
# You can move that to a different file under sites-available/ and symlink that
81+
# to sites-enabled/ to enable it.
82+
#
83+
#server {
84+
# listen 80;
85+
# listen [::]:80;
86+
#
87+
# server_name example.com;
88+
#
89+
# root /var/www/example.com;
90+
# index index.html;
91+
#
92+
# location / {
93+
# try_files $uri $uri/ =404;
94+
# }
95+
#}

0 commit comments

Comments
 (0)