Browse Source

nginx

split-pipe
Hendrik Langer 4 years ago
parent
commit
79f76c6788
  1. 60
      README.md
  2. 4
      raspberry/roberto.py
  3. 2
      raspberry/roberto/__init__.py
  4. 11
      raspberry/roberto/views/websocket/templates/camera.html

60
README.md

@ -48,3 +48,63 @@ https://github.com/nanomosfet/WebRTC-Flask-server/blob/master/webRTCserver/webRT
http://blog.nirbheek.in/2018/02/gstreamer-webrtc.html http://blog.nirbheek.in/2018/02/gstreamer-webrtc.html
https://gitlab.freedesktop.org/gstreamer/gst-examples/-/tree/master/webrtc/sendrecv/gst https://gitlab.freedesktop.org/gstreamer/gst-examples/-/tree/master/webrtc/sendrecv/gst
https://github.com/thaytan/gst-rpicamsrc/blob/master/examples/webrtc-unidirectional-h264.c
## nginx.conf
```
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name roberto.xd0.de;
ssl_certificate /etc/letsencrypt/live/roberto.xd0.de/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/roberto.xd0.de/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
access_log /var/log/nginx/roberto_access.log;
error_log /var/log/nginx/roberto_error.log;
root /var/www/html;
index index.html index.htm;
proxy_buffering off;
location / {
include proxy_params;
# client_max_body_size 0;
proxy_pass http://172.16.85.42:5000;
}
# location /static {
# alias <path-to-your-application>/static;
# expires 30d;
# }
location /socket.io {
include proxy_params;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_buffering off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass http://172.16.85.42:5000/socket.io;
}
location ~ /\.ht {
deny all;
}
}
```

4
raspberry/roberto.py

@ -14,6 +14,6 @@ if __name__ == '__main__':
app, app,
host='0.0.0.0', host='0.0.0.0',
port=5000, port=5000,
certfile='cert.pem', # certfile='cert.pem',
keyfile='key.pem' # keyfile='key.pem'
) )

2
raspberry/roberto/__init__.py

@ -55,7 +55,7 @@ def initialize_extensions(app):
from roberto.model import db from roberto.model import db
db.init_app(app) db.init_app(app)
#login.init_app(app) #login.init_app(app)
socketio.init_app(app) socketio.init_app(app, cors_allowed_origins="*")
pass pass
def register_blueprints(app): def register_blueprints(app):

11
raspberry/roberto/views/websocket/templates/camera.html

@ -10,6 +10,7 @@
<script src="{{ url_for('static', filename='js/jquery.min.js') }}"></script> <script src="{{ url_for('static', filename='js/jquery.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script> <script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/socket.io.js') }}"></script> <script src="{{ url_for('static', filename='js/socket.io.js') }}"></script>
<script type="text/javascript" src="https://webrtc.github.io/adapter/adapter-latest.js"></script><!-- DEBUG REMOVE ME //-->
</head> </head>
<body> <body>
@ -26,7 +27,7 @@
const PC_CONFIG = {}; const PC_CONFIG = {};
var room = '{{room}}'; var room = '{{room}}';
var socket = io.connect(SIGNALING_SERVER_URL, { autoConnect: false }); var socket = io.connect(SIGNALING_SERVER_URL, { autoConnect: false, transports: [ 'websocket' ] });
socket.on('connect', function(){ socket.on('connect', function(){
console.log("Connected...!", socket.connected) console.log("Connected...!", socket.connected)
@ -141,8 +142,16 @@ let handleSignalingData = (data) => {
} }
}; };
function foo() {
if (pc) {
var sig_state = pc.signalingState;
console.log("signaling state: ", sig_state);
}
}
// Start connection // Start connection
getLocalStream(); getLocalStream();
setInterval(foo, 5000);
</script> </script>
</body> </body>

Loading…
Cancel
Save