Skip to content

Commit

Permalink
bugfix revproxy for django >v3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
IoTree committed Sep 10, 2021
1 parent 1bf01c3 commit a196976
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 22 deletions.
10 changes: 7 additions & 3 deletions IoTree_Gateway/giotree/LinkGateways.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ do
echo ${string} >>/etc/mosquitto/mosquitto.conf
string="remote_username ${Username}"
echo ${string} >>/etc/mosquitto/mosquitto.conf
echo 'bridge_cafile /etc/mosquitto/certs/DST_Root_CA_X3.pem' >>/etc/mosquitto/mosquitto.conf
if [ "$Port" = "8883"]; then
echo 'bridge_cafile /etc/mosquitto/certs/DST_Root_CA_X3.pem' >>/etc/mosquitto/mosquitto.conf
fi
string="remote_clientid ${GatewayID}"
echo ${string} >>/etc/mosquitto/mosquitto.conf
string="topic # both 2 sensorbase/ gateways/${Username}/${GatewayID}/"
Expand All @@ -51,12 +53,14 @@ do
string="connection ext${arline[0]}"
echo ${string} >>/etc/mosquitto/mosquitto.conf
echo 'cleansession false' >>/etc/mosquitto/mosquitto.conf
echo 'address iot.beratende-ingenieure.it:8883' >>/etc/mosquitto/mosquitto.conf
echo 'address ${Hostname}:${Port}' >>/etc/mosquitto/mosquitto.conf
string="remote_password ${Password}"
echo ${string} >>/etc/mosquitto/mosquitto.conf
string="remote_username ${Username}"
echo ${string} >>/etc/mosquitto/mosquitto.conf
echo 'bridge_cafile /etc/mosquitto/certs/DST_Root_CA_X3.pem' >>/etc/mosquitto/mosquitto.conf
if [ "$Port" = "8883"]; then
echo 'bridge_cafile /etc/mosquitto/certs/DST_Root_CA_X3.pem' >>/etc/mosquitto/mosquitto.conf
fi
string="remote_clientid ext${arline[0]}"
echo ${string} >>/etc/mosquitto/mosquitto.conf
string="topic ${arline[1]} in 2 gateway/${arline[0]}/ gateways/${Username}/${arline[0]}/"
Expand Down
7 changes: 7 additions & 0 deletions bugfix_revproxy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -e


x=$1
sed -i '48s/.*/ logger.debug('Response headers: %s', response.headers)/' /home/$x/dj_iot/venv2/lib/python3.9/site-packages/revproxyfile.txt
sed -i '127s/.*/ logger.debug('Response headers: %s', response.headers)/' /home/$x/dj_iot/venv2/lib/python3.9/site-packages/utils.txt
2 changes: 1 addition & 1 deletion home_user/dj_iot/dj_iot/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,6 @@
#SECURE_SSL_REDIRECT = True
#SESSION_COOKIE_SECURE = True
#CSRF_COOKIE_SECURE = True
#X_FRAME_OPTIONS = "DENY"
X_FRAME_OPTIONS = "SAMEORIGIN"
#SECURE_HSTS_INCLUDE_SUBDOMAINS = True
#SECURE_HSTS_PRELOAD = True
1 change: 0 additions & 1 deletion home_user/dj_iot/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ markdown
django-filter
django-ranged-response
captcha
pymongo
django-simple-captcha
influxdb
gunicorn
Expand Down
2 changes: 1 addition & 1 deletion home_user/dj_iot/users/templates/users/setup_rpi.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h5><a class="mr-2" >How to setup Gateway / Raspberry Pi</a></h5>
</div>
<a>We going to start with some commands on our Rpi</a>
<p>We need to download the repository. Enter the following command.</p>
<pre style="background-color: #C0C0C0">curl -O https:--your site name--/media/downloadfiles/IoTree_Gateway_V_1.1.zip</pre>
<pre style="background-color: #C0C0C0">curl -O https:--your site name--/media/downloadfiles/IoTree_Gateway_V_2.0.zip</pre>
<p>Or download it manually:</p>
<form method="post">
{% csrf_token %}
Expand Down
5 changes: 4 additions & 1 deletion home_user/dj_iot/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,10 @@ def manual(request):
# func. for redirect to a grafana iframe via modif.
@login_required
def tografana(request):
return render(request, 'users/dashboard.html')
# return render(request, 'users/dashboard.html')
# somthing not wroking properly with iframe needs more investiagtion.
# work around no iframe via redirect to grafana proxy address
return redirect(config['GRAFA_ADDRESS'])


# modified page for render Grafana in iframe
Expand Down
13 changes: 12 additions & 1 deletion lib/tmp.grafana.ini.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ domain = localhost
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana
# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons.
;serve_from_sub_path = false
serve_from_sub_path = true
# Log web requests
;router_logging = false
Expand Down Expand Up @@ -621,6 +621,17 @@ auto_sign_up = false
[grafana_com]
;url = https://grafana.com
#################################### Grafana Live ##########################################
[live]
# max_connections to Grafana Live WebSocket endpoint per Grafana server instance. See Grafana Live docs
# if you are planning to make it higher than default 100 since this can require some OS and infrastructure
# tuning. 0 disables Live, -1 means unlimited connections.
max_connections = 0
# allowed_origins is a comma-separated list of origins that can establish connection with Grafana Live.
# If not set then origin will be matched over root_url. Supports wildcard symbol "*".
;allowed_origins =
#################################### Distributed tracing ############
[tracing.jaeger]
# Enable by setting the address sending traces to jaeger (ex localhost:6831)
Expand Down
10 changes: 5 additions & 5 deletions lib/tmp.nginx-nossl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ server {
server_name $DOMAIN;
location /grafana/ {
proxy_pass http://localhost:3000/;
proxy_set_header Host \$host;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
}
# location /grafana/ {
# proxy_pass http://localhost:3000/;
# proxy_set_header Host \$host;
# proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
# }
location = /favicon.ico { access_log off; log_not_found off; }
Expand Down
18 changes: 9 additions & 9 deletions lib/tmp.nginx-ssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ server {
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
location /grafana/ {
proxy_pass http://localhost:3000/;
proxy_set_header Host \$host;
proxy_redirect http:// https://;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection \$connection_upgrade;
}
# location /grafana/ {
# proxy_pass http://localhost:3000/;
# proxy_set_header Host \$host;
# proxy_redirect http:// https://;
# proxy_http_version 1.1;
# proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
# proxy_set_header Upgrade \$http_upgrade;
# proxy_set_header Connection \$connection_upgrade;
# }
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
Expand Down
2 changes: 2 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ if [ "$nginx" = true ]; then
fi


#bugfix for django-revproxy plugin
./bugfix_revproxy.sh '$myvariable'


echo "-Endpoints- -port-"
Expand Down

0 comments on commit a196976

Please sign in to comment.