Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make TLS optional #17

Merged
merged 2 commits into from
Sep 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions examples/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ def main():
loop = asyncio.get_event_loop()

# Create SSL context
ssl_context = saltyrtc.util.create_ssl_context(
certfile=require_env('SALTYRTC_TLS_CERT'),
keyfile=require_env('SALTYRTC_TLS_KEY'),
)
if env('SALTYRTC_DISABLE_TLS') != 'yes-and-i-know-what-im-doing':
ssl_context = saltyrtc.util.create_ssl_context(
certfile=require_env('SALTYRTC_TLS_CERT'),
keyfile=require_env('SALTYRTC_TLS_KEY'),
)
else:
ssl_context = None

# Start server
coroutine = saltyrtc.serve(ssl_context, port=int(env('SALTYRTC_PORT', '8765')))
Expand Down
42 changes: 42 additions & 0 deletions examples/nginx.conf.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Nginx example configuration as a WebSocket proxy with TLS termination.

map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}

upstream websocket {
server 127.0.0.1:8765;
}

server {
listen 80 default_server;
listen 443 default_server;
listen [::]:80 default_server;
listen [::]:443 default_server;
server_name _;
return 444;
}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name saltyrtc.example.com;

# TLS
add_header Strict-Transport-Security max-age=2592000;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;

# Logging
access_log /var/log/nginx/saltyrtc.example.com.access.log;
error_log /var/log/nginx/saltyrtc.example.com.error.log error;

location / {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 60s;
}
}