mirror of
https://github.com/hassio-addons/addon-vscode.git
synced 2025-05-03 18:51:23 +00:00
✨ Adds Hassio Ingress support + General refactor
This commit is contained in:
parent
5b716764fa
commit
2d030869ee
29 changed files with 321 additions and 248 deletions
25
README.md
25
README.md
|
@ -48,8 +48,7 @@ comparison to installing any other Hass.io add-on.
|
|||
1. Start the "Visual Studio Code" add-on.
|
||||
1. Check the logs of the "Visual Studio Code" add-on to see if everything went
|
||||
well.
|
||||
1. Click the "OPEN WEB UI" button to open Visual Studio Code and use the same
|
||||
username & password as you would use with the Home Assistant frontend.
|
||||
1. Click the "OPEN WEB UI" button to open Visual Studio Code.
|
||||
|
||||
**NOTE**: Do not add this repository to Hass.io, please use:
|
||||
`https://github.com/hassio-addons/repository`.
|
||||
|
@ -70,7 +69,7 @@ Example add-on configuration:
|
|||
"mariadb-client"
|
||||
],
|
||||
"init_commands": [
|
||||
"pip3 install yamllint"
|
||||
"ls -la"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
@ -99,6 +98,9 @@ you are troubleshooting.
|
|||
|
||||
Enables/Disables SSL (HTTPS). Set it `true` to enable it, `false` otherwise.
|
||||
|
||||
**Note**: _The SSL settings only apply to direct access and has no effect
|
||||
on the Hass.io Ingress service._
|
||||
|
||||
### Option: `certfile`
|
||||
|
||||
The certificate file to use for SSL.
|
||||
|
@ -133,23 +135,6 @@ authentication on the VSCode by setting it to `true`.
|
|||
**Note**: _We STRONGLY suggest, not to use this, even if this add-on is
|
||||
only exposed to your internal network. USE AT YOUR OWN RISK!_
|
||||
|
||||
## Embedding into Home Assistant
|
||||
|
||||
It is possible to embed VSCode directly into Home Assistant, allowing
|
||||
you to access your VSCode through the Home Assistant frontend.
|
||||
|
||||
Home Assistant provides the `panel_iframe` component, for these purposes.
|
||||
|
||||
Example configuration:
|
||||
|
||||
```yaml
|
||||
panel_iframe:
|
||||
vscode:
|
||||
title: Visual Studio Code
|
||||
icon: mdi:visual-studio-code
|
||||
url: https://address.to.your.hass.io:1337
|
||||
```
|
||||
|
||||
## Known issues and limitations
|
||||
|
||||
- This add-on currently only supports AMD64 machines, although we hope
|
||||
|
|
|
@ -123,8 +123,12 @@ RUN \
|
|||
\
|
||||
&& rm -fr \
|
||||
/tmp/* \
|
||||
/etc/nginx \
|
||||
/var/{cache,log}/* \
|
||||
/var/lib/apt/lists/*
|
||||
/var/lib/apt/lists/* \
|
||||
\
|
||||
&& mkdir -p /var/log/nginx \
|
||||
&& touch /var/log/nginx/error.log
|
||||
|
||||
# Copy root filesystem
|
||||
COPY rootfs /
|
||||
|
|
|
@ -4,8 +4,11 @@
|
|||
"slug": "vscode",
|
||||
"description": "Fully featured VSCode experience, to edit your HA config in the browser, including auto-completion!",
|
||||
"url": "https://github.com/hassio-addons/addon-vscode",
|
||||
"webui": "[PROTO:ssl]://[HOST]:[PORT:1337]",
|
||||
"webui": "[PROTO:ssl]://[HOST]:[PORT:80]",
|
||||
"ingress": true,
|
||||
"ingress_port": 1337,
|
||||
"startup": "services",
|
||||
"homeassistant": "0.91.3",
|
||||
"arch": [
|
||||
"amd64"
|
||||
],
|
||||
|
@ -14,10 +17,12 @@
|
|||
"auth_api": true,
|
||||
"hassio_role": "manager",
|
||||
"homeassistant_api": true,
|
||||
"host_network": false,
|
||||
"auto_uart": true,
|
||||
"ports": {
|
||||
"1337/tcp": 1337
|
||||
"80/tcp": null
|
||||
},
|
||||
"ports_description": {
|
||||
"80/tcp": "VSCode (Not required for Hass.io Ingress)"
|
||||
},
|
||||
"map": [
|
||||
"config:rw",
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Visual Studio Code
|
||||
# This files check if all user configuration requirements are met
|
||||
# ==============================================================================
|
||||
bashio::config.require.ssl
|
|
@ -1,17 +0,0 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Visual Studio Code
|
||||
# Configures NGINX for use with code-server
|
||||
# ==============================================================================
|
||||
declare certfile
|
||||
declare keyfile
|
||||
|
||||
mkdir -p /var/log/nginx
|
||||
|
||||
if bashio::config.true 'ssl'; then
|
||||
certfile=$(bashio::config 'certfile')
|
||||
keyfile=$(bashio::config 'keyfile')
|
||||
|
||||
sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/nginx-ssl.conf
|
||||
sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/nginx-ssl.conf
|
||||
fi
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Visual Studio Code
|
||||
# Links some common directories to the user's home folder for convenience
|
||||
# ==============================================================================
|
||||
readonly -a directories=(addons backup config share ssl)
|
||||
|
||||
for dir in "${directories[@]}"; do
|
||||
ln -s "/${dir}" "${HOME}/${dir}" \
|
||||
|| bashio::log.warning "Failed linking common directory: ${dir}"
|
||||
done
|
|
@ -1,17 +0,0 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Visual Studio Code
|
||||
# Sets up the users .ssh folder to be persistent
|
||||
# ==============================================================================
|
||||
readonly SSH_USER_PATH=/data/.ssh
|
||||
|
||||
if ! bashio::fs.directory_exists "${SSH_USER_PATH}"; then
|
||||
mkdir -p "${SSH_USER_PATH}" \
|
||||
|| bashio::exit.nok 'Failed to create a persistent .ssh folder'
|
||||
|
||||
chmod 700 "${SSH_USER_PATH}" \
|
||||
|| bashio::exit.nok \
|
||||
'Failed setting permissions on persistent .ssh folder'
|
||||
fi
|
||||
|
||||
ln -s "${SSH_USER_PATH}" ~/.ssh
|
|
@ -1,22 +0,0 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Visual Studio Code
|
||||
# Sets up the users git global config to be persistent
|
||||
# ==============================================================================
|
||||
readonly GIT_USER_PATH=/data/git
|
||||
|
||||
if ! bashio::fs.directory_exists "${GIT_USER_PATH}"; then
|
||||
mkdir -p "${GIT_USER_PATH}" \
|
||||
|| bashio::exit.nok 'Failed to create a persistent git folder'
|
||||
|
||||
chmod 700 "${GIT_USER_PATH}" \
|
||||
|| bashio::exit.nok \
|
||||
'Failed setting permissions on persistent git folder'
|
||||
fi
|
||||
|
||||
if ! bashio::fs.file_exists "${GIT_USER_PATH}/.gitconfig"; then
|
||||
touch "${GIT_USER_PATH}/.gitconfig" \
|
||||
|| bashio::exit.nok 'Failed to create .gitconfig'
|
||||
fi
|
||||
|
||||
ln -s "${GIT_USER_PATH}/.gitconfig" ~/.gitconfig
|
|
@ -1,14 +0,0 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Visual Studio Code
|
||||
# Install user configured/requested packages
|
||||
# ==============================================================================
|
||||
if bashio::config.has_value 'packages'; then
|
||||
apt update \
|
||||
|| bashio::exit.nok 'Failed updating Ubuntu packages repository indexes'
|
||||
|
||||
for package in $(bashio::config 'packages'); do
|
||||
apt-get install -y "$package" \
|
||||
|| bashio::exit.nok "Failed installing package ${package}"
|
||||
done
|
||||
fi
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Visual Studio Code
|
||||
# Executes user configured/requested commands on startup
|
||||
# ==============================================================================
|
||||
if bashio::config.has_value 'init_commands'; then
|
||||
while read -r cmd; do
|
||||
eval "${cmd}" \
|
||||
|| bashio::exit.nok "Failed executing init command: ${cmd}"
|
||||
done <<< "$(bashio::config 'init_commands')"
|
||||
fi
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Visual Studio Code
|
||||
# Updates/installs build-in extensions and set up initial user configuration.
|
||||
# Sets up code-server.
|
||||
# ==============================================================================
|
||||
|
||||
# Ensure persistent data folder exists
|
32
vscode/rootfs/etc/cont-init.d/nginx.sh
Normal file
32
vscode/rootfs/etc/cont-init.d/nginx.sh
Normal file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Visual Studio Code
|
||||
# Configures NGINX for use with code-server
|
||||
# ==============================================================================
|
||||
declare port
|
||||
declare certfile
|
||||
declare ingress_interface
|
||||
declare ingress_port
|
||||
declare keyfile
|
||||
|
||||
port=$(bashio::addon.port 80)
|
||||
if bashio::var.has_value "${port}"; then
|
||||
bashio::config.require.ssl
|
||||
|
||||
if bashio::config.true 'ssl'; then
|
||||
certfile=$(bashio::config 'certfile')
|
||||
keyfile=$(bashio::config 'keyfile')
|
||||
|
||||
mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf
|
||||
sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/servers/direct.conf
|
||||
sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/servers/direct.conf
|
||||
|
||||
else
|
||||
mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
ingress_port=$(bashio::addon.ingress_port)
|
||||
ingress_interface=$(bashio::addon.ip_address)
|
||||
sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf
|
||||
sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf
|
53
vscode/rootfs/etc/cont-init.d/user.sh
Normal file
53
vscode/rootfs/etc/cont-init.d/user.sh
Normal file
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Visual Studio Code
|
||||
# Persists user settings and installs custom user packages.
|
||||
# ==============================================================================
|
||||
readonly GIT_USER_PATH=/data/git
|
||||
readonly SSH_USER_PATH=/data/.ssh
|
||||
|
||||
# Store SSH settings in add-on data folder
|
||||
if ! bashio::fs.directory_exists "${SSH_USER_PATH}"; then
|
||||
mkdir -p "${SSH_USER_PATH}" \
|
||||
|| bashio::exit.nok 'Failed to create a persistent .ssh folder'
|
||||
|
||||
chmod 700 "${SSH_USER_PATH}" \
|
||||
|| bashio::exit.nok \
|
||||
'Failed setting permissions on persistent .ssh folder'
|
||||
fi
|
||||
ln -s "${SSH_USER_PATH}" ~/.ssh
|
||||
|
||||
# Store user GIT settings in add-on data folder
|
||||
if ! bashio::fs.directory_exists "${GIT_USER_PATH}"; then
|
||||
mkdir -p "${GIT_USER_PATH}" \
|
||||
|| bashio::exit.nok 'Failed to create a persistent git folder'
|
||||
|
||||
chmod 700 "${GIT_USER_PATH}" \
|
||||
|| bashio::exit.nok \
|
||||
'Failed setting permissions on persistent git folder'
|
||||
fi
|
||||
|
||||
if ! bashio::fs.file_exists "${GIT_USER_PATH}/.gitconfig"; then
|
||||
touch "${GIT_USER_PATH}/.gitconfig" \
|
||||
|| bashio::exit.nok 'Failed to create .gitconfig'
|
||||
fi
|
||||
ln -s "${GIT_USER_PATH}/.gitconfig" ~/.gitconfig
|
||||
|
||||
# Install user configured/requested packages
|
||||
if bashio::config.has_value 'packages'; then
|
||||
apt update \
|
||||
|| bashio::exit.nok 'Failed updating Ubuntu packages repository indexes'
|
||||
|
||||
for package in $(bashio::config 'packages'); do
|
||||
apt-get install -y "$package" \
|
||||
|| bashio::exit.nok "Failed installing package ${package}"
|
||||
done
|
||||
fi
|
||||
|
||||
# Executes user configured/requested commands on startup
|
||||
if bashio::config.has_value 'init_commands'; then
|
||||
while read -r cmd; do
|
||||
eval "${cmd}" \
|
||||
|| bashio::exit.nok "Failed executing init command: ${cmd}"
|
||||
done <<< "$(bashio::config 'init_commands')"
|
||||
fi
|
96
vscode/rootfs/etc/nginx/includes/mime.types
Normal file
96
vscode/rootfs/etc/nginx/includes/mime.types
Normal file
|
@ -0,0 +1,96 @@
|
|||
types {
|
||||
text/html html htm shtml;
|
||||
text/css css;
|
||||
text/xml xml;
|
||||
image/gif gif;
|
||||
image/jpeg jpeg jpg;
|
||||
application/javascript js;
|
||||
application/atom+xml atom;
|
||||
application/rss+xml rss;
|
||||
|
||||
text/mathml mml;
|
||||
text/plain txt;
|
||||
text/vnd.sun.j2me.app-descriptor jad;
|
||||
text/vnd.wap.wml wml;
|
||||
text/x-component htc;
|
||||
|
||||
image/png png;
|
||||
image/svg+xml svg svgz;
|
||||
image/tiff tif tiff;
|
||||
image/vnd.wap.wbmp wbmp;
|
||||
image/webp webp;
|
||||
image/x-icon ico;
|
||||
image/x-jng jng;
|
||||
image/x-ms-bmp bmp;
|
||||
|
||||
font/woff woff;
|
||||
font/woff2 woff2;
|
||||
|
||||
application/java-archive jar war ear;
|
||||
application/json json;
|
||||
application/mac-binhex40 hqx;
|
||||
application/msword doc;
|
||||
application/pdf pdf;
|
||||
application/postscript ps eps ai;
|
||||
application/rtf rtf;
|
||||
application/vnd.apple.mpegurl m3u8;
|
||||
application/vnd.google-earth.kml+xml kml;
|
||||
application/vnd.google-earth.kmz kmz;
|
||||
application/vnd.ms-excel xls;
|
||||
application/vnd.ms-fontobject eot;
|
||||
application/vnd.ms-powerpoint ppt;
|
||||
application/vnd.oasis.opendocument.graphics odg;
|
||||
application/vnd.oasis.opendocument.presentation odp;
|
||||
application/vnd.oasis.opendocument.spreadsheet ods;
|
||||
application/vnd.oasis.opendocument.text odt;
|
||||
application/vnd.openxmlformats-officedocument.presentationml.presentation
|
||||
pptx;
|
||||
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
|
||||
xlsx;
|
||||
application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
||||
docx;
|
||||
application/vnd.wap.wmlc wmlc;
|
||||
application/x-7z-compressed 7z;
|
||||
application/x-cocoa cco;
|
||||
application/x-java-archive-diff jardiff;
|
||||
application/x-java-jnlp-file jnlp;
|
||||
application/x-makeself run;
|
||||
application/x-perl pl pm;
|
||||
application/x-pilot prc pdb;
|
||||
application/x-rar-compressed rar;
|
||||
application/x-redhat-package-manager rpm;
|
||||
application/x-sea sea;
|
||||
application/x-shockwave-flash swf;
|
||||
application/x-stuffit sit;
|
||||
application/x-tcl tcl tk;
|
||||
application/x-x509-ca-cert der pem crt;
|
||||
application/x-xpinstall xpi;
|
||||
application/xhtml+xml xhtml;
|
||||
application/xspf+xml xspf;
|
||||
application/zip zip;
|
||||
|
||||
application/octet-stream bin exe dll;
|
||||
application/octet-stream deb;
|
||||
application/octet-stream dmg;
|
||||
application/octet-stream iso img;
|
||||
application/octet-stream msi msp msm;
|
||||
|
||||
audio/midi mid midi kar;
|
||||
audio/mpeg mp3;
|
||||
audio/ogg ogg;
|
||||
audio/x-m4a m4a;
|
||||
audio/x-realaudio ra;
|
||||
|
||||
video/3gpp 3gpp 3gp;
|
||||
video/mp2t ts;
|
||||
video/mp4 mp4;
|
||||
video/mpeg mpeg mpg;
|
||||
video/quicktime mov;
|
||||
video/webm webm;
|
||||
video/x-flv flv;
|
||||
video/x-m4v m4v;
|
||||
video/x-mng mng;
|
||||
video/x-ms-asf asx asf;
|
||||
video/x-ms-wmv wmv;
|
||||
video/x-msvideo avi;
|
||||
}
|
15
vscode/rootfs/etc/nginx/includes/proxy_params.conf
Normal file
15
vscode/rootfs/etc/nginx/includes/proxy_params.conf
Normal file
|
@ -0,0 +1,15 @@
|
|||
proxy_http_version 1.1;
|
||||
proxy_ignore_client_abort off;
|
||||
proxy_read_timeout 86400s;
|
||||
proxy_redirect off;
|
||||
proxy_send_timeout 86400s;
|
||||
proxy_max_temp_file_size 0;
|
||||
|
||||
proxy_set_header Accept-Encoding "gzip";
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-NginX-Proxy true;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
1
vscode/rootfs/etc/nginx/includes/resolver.conf
Normal file
1
vscode/rootfs/etc/nginx/includes/resolver.conf
Normal file
|
@ -0,0 +1 @@
|
|||
resolver 127.0.0.11;
|
6
vscode/rootfs/etc/nginx/includes/server_params.conf
Normal file
6
vscode/rootfs/etc/nginx/includes/server_params.conf
Normal file
|
@ -0,0 +1,6 @@
|
|||
root /dev/null;
|
||||
server_name $hostname;
|
||||
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
add_header X-Robots-Tag none;
|
9
vscode/rootfs/etc/nginx/includes/ssl_params.conf
Normal file
9
vscode/rootfs/etc/nginx/includes/ssl_params.conf
Normal file
|
@ -0,0 +1,9 @@
|
|||
ssl_protocols TLSv1.2;
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA;
|
||||
ssl_ecdh_curve secp384r1;
|
||||
ssl_session_timeout 10m;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_tickets off;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
3
vscode/rootfs/etc/nginx/includes/upstream.conf
Normal file
3
vscode/rootfs/etc/nginx/includes/upstream.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
upstream backend {
|
||||
server 127.0.0.1:8443;
|
||||
}
|
1
vscode/rootfs/etc/nginx/modules/ndk_http.conf
Normal file
1
vscode/rootfs/etc/nginx/modules/ndk_http.conf
Normal file
|
@ -0,0 +1 @@
|
|||
load_module "/usr/lib/nginx/modules/ndk_http_module.so";
|
1
vscode/rootfs/etc/nginx/modules/ngx_http_lua.conf
Normal file
1
vscode/rootfs/etc/nginx/modules/ngx_http_lua.conf
Normal file
|
@ -0,0 +1 @@
|
|||
load_module "/usr/lib/nginx/modules/ngx_http_lua_module.so";
|
|
@ -1,71 +0,0 @@
|
|||
worker_processes 1;
|
||||
pid /var/run/nginx.pid;
|
||||
error_log stderr;
|
||||
env HASSIO_TOKEN;
|
||||
env DISABLE_HA_AUTHENTICATION;
|
||||
load_module "/usr/lib/nginx/modules/ndk_http_module.so";
|
||||
load_module "/usr/lib/nginx/modules/ngx_http_lua_module.so";
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
access_log stdout;
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
lua_shared_dict auths 16k;
|
||||
resolver 127.0.0.11;
|
||||
|
||||
upstream code {
|
||||
ip_hash;
|
||||
server 127.0.0.1:8443;
|
||||
}
|
||||
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
server {
|
||||
server_name hassio.local;
|
||||
listen 1337 default_server ssl;
|
||||
root /dev/null;
|
||||
|
||||
ssl_certificate /ssl/%%certfile%%;
|
||||
ssl_certificate_key /ssl/%%keyfile%%;
|
||||
ssl_protocols TLSv1.2;
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA;
|
||||
ssl_ecdh_curve secp384r1;
|
||||
ssl_session_timeout 10m;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_tickets off;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
add_header X-Robots-Tag none;
|
||||
|
||||
location / {
|
||||
access_by_lua_file /etc/nginx/ha-auth.lua;
|
||||
|
||||
proxy_redirect off;
|
||||
proxy_pass http://code;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Authorization "";
|
||||
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-NginX-Proxy true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,57 +1,58 @@
|
|||
worker_processes 1;
|
||||
# Run nginx in foreground.
|
||||
daemon off;
|
||||
|
||||
# This is run inside Docker.
|
||||
user root;
|
||||
|
||||
# Pid storage location.
|
||||
pid /var/run/nginx.pid;
|
||||
error_log stderr;
|
||||
|
||||
# Set number of worker processes.
|
||||
worker_processes 1;
|
||||
|
||||
# Enables the use of JIT for regular expressions to speed-up their processing.
|
||||
pcre_jit on;
|
||||
|
||||
# Write error log to Hass.io add-on log.
|
||||
error_log /proc/1/fd/1 error;
|
||||
|
||||
# Load allowed environment vars
|
||||
env HASSIO_TOKEN;
|
||||
env DISABLE_HA_AUTHENTICATION;
|
||||
load_module "/usr/lib/nginx/modules/ndk_http_module.so";
|
||||
load_module "/usr/lib/nginx/modules/ngx_http_lua_module.so";
|
||||
|
||||
# Load dynamic modules.
|
||||
include /etc/nginx/modules/*.conf;
|
||||
|
||||
# Max num of simultaneous connections by a worker process.
|
||||
events {
|
||||
worker_connections 1024;
|
||||
worker_connections 512;
|
||||
}
|
||||
|
||||
http {
|
||||
access_log stdout;
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
lua_shared_dict auths 16k;
|
||||
resolver 127.0.0.11;
|
||||
include /etc/nginx/includes/mime.types;
|
||||
|
||||
upstream code {
|
||||
ip_hash;
|
||||
server 127.0.0.1:8443;
|
||||
}
|
||||
log_format hassio '[$time_local] $status '
|
||||
'$http_x_forwarded_for($remote_addr) '
|
||||
'$request ($http_user_agent)';
|
||||
|
||||
access_log /proc/1/fd/1 hassio;
|
||||
client_max_body_size 4G;
|
||||
default_type application/octet-stream;
|
||||
gzip on;
|
||||
keepalive_timeout 65;
|
||||
lua_shared_dict auths 16k;
|
||||
sendfile on;
|
||||
server_tokens off;
|
||||
tcp_nodelay on;
|
||||
tcp_nopush on;
|
||||
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
server {
|
||||
server_name hassio.local;
|
||||
listen 1337 default_server;
|
||||
root /dev/null;
|
||||
include /etc/nginx/includes/resolver.conf;
|
||||
include /etc/nginx/includes/upstream.conf;
|
||||
|
||||
location / {
|
||||
access_by_lua_file /etc/nginx/ha-auth.lua;
|
||||
|
||||
proxy_redirect off;
|
||||
proxy_pass http://code;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Authorization "";
|
||||
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-NginX-Proxy true;
|
||||
proxy_read_timeout 86400s;
|
||||
proxy_send_timeout 86400s;
|
||||
}
|
||||
}
|
||||
include /etc/nginx/servers/*.conf;
|
||||
}
|
||||
|
|
16
vscode/rootfs/etc/nginx/servers/direct-ssl.disabled
Normal file
16
vscode/rootfs/etc/nginx/servers/direct-ssl.disabled
Normal file
|
@ -0,0 +1,16 @@
|
|||
server {
|
||||
listen 80 default_server ssl http2;
|
||||
|
||||
include /etc/nginx/includes/server_params.conf;
|
||||
include /etc/nginx/includes/ssl_params.conf;
|
||||
include /etc/nginx/includes/proxy_params.conf;
|
||||
|
||||
ssl on;
|
||||
ssl_certificate /ssl/%%certfile%%;
|
||||
ssl_certificate_key /ssl/%%keyfile%%;
|
||||
|
||||
location / {
|
||||
access_by_lua_file /etc/nginx/lua/ha-auth.lua;
|
||||
proxy_pass http://backend;
|
||||
}
|
||||
}
|
11
vscode/rootfs/etc/nginx/servers/direct.disabled
Normal file
11
vscode/rootfs/etc/nginx/servers/direct.disabled
Normal file
|
@ -0,0 +1,11 @@
|
|||
server {
|
||||
listen 80 default_server;
|
||||
|
||||
include /etc/nginx/includes/server_params.conf;
|
||||
include /etc/nginx/includes/proxy_params.conf;
|
||||
|
||||
location / {
|
||||
access_by_lua_file /etc/nginx/lua/ha-auth.lua;
|
||||
proxy_pass http://backend;
|
||||
}
|
||||
}
|
13
vscode/rootfs/etc/nginx/servers/ingress.conf
Normal file
13
vscode/rootfs/etc/nginx/servers/ingress.conf
Normal file
|
@ -0,0 +1,13 @@
|
|||
server {
|
||||
listen %%interface%%:1337 default_server;
|
||||
|
||||
include /etc/nginx/includes/server_params.conf;
|
||||
include /etc/nginx/includes/proxy_params.conf;
|
||||
|
||||
location / {
|
||||
allow 172.30.32.2;
|
||||
deny all;
|
||||
|
||||
proxy_pass http://backend;
|
||||
}
|
||||
}
|
|
@ -8,7 +8,8 @@ declare -a options
|
|||
bashio::log.info 'Starting the code server...'
|
||||
|
||||
options+=(--port 8443)
|
||||
options+=(--data-dir "/data/vscode")
|
||||
options+=(--user-data-dir "/data/vscode")
|
||||
options+=(--extensions-dir "/data/vscode/extensions")
|
||||
options+=(--host 127.0.0.1)
|
||||
options+=(--allow-http)
|
||||
|
||||
|
|
|
@ -3,14 +3,9 @@
|
|||
# Community Hass.io Add-ons: Visual Studio Code
|
||||
# Runs the Nginx daemon
|
||||
# ==============================================================================
|
||||
declare -a options
|
||||
|
||||
# Wait for code-server to become available
|
||||
s6-svwait -u -t 5000 /var/run/s6/services/code
|
||||
timeout 15 \
|
||||
bash -c \
|
||||
'until echo > /dev/tcp/localhost/8443 ; do sleep 0.5; done' \
|
||||
> /dev/null 2>&1
|
||||
bashio::net.wait_for 8443
|
||||
|
||||
bashio::log.info "Starting NGinx..."
|
||||
|
||||
|
@ -19,10 +14,4 @@ if bashio::config.true 'leave_front_door_open'; then
|
|||
export DISABLE_HA_AUTHENTICATION=true
|
||||
fi
|
||||
|
||||
options+=(-g "daemon off;")
|
||||
|
||||
if bashio::config.true 'ssl'; then
|
||||
options+=(-c /etc/nginx/nginx-ssl.conf)
|
||||
fi
|
||||
|
||||
exec nginx "${options[@]}"
|
||||
exec nginx
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue