Skip to content

Instantly share code, notes, and snippets.

@wzulfikar
Created December 28, 2016 20:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wzulfikar/ccc5e66670c4389d958303229ff79206 to your computer and use it in GitHub Desktop.
Save wzulfikar/ccc5e66670c4389d958303229ff79206 to your computer and use it in GitHub Desktop.
traccar config for nginx: proxy set for web & websocket. tested with cloudflare (https set to flexible). original: https://www.traccar.org/forums/topic/nginx-alias-configuration/
server {
listen 443;
listen 80;
server_name tracking.domain.com;
add_header Strict-Transport-Security max-age=63072000;
#client_max_body_size 200M;
# Security features
if ($http_user_agent ~* LWP::Simple|BBBike|wget) {
return 403;
}
if ($http_user_agent ~* msnbot|scrapbot) {
return 403;
}
# Traccar Setup
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect http://0.0.0.0:8082/ /;
proxy_redirect ws://0.0.0.0:8082/api/socket /api/socket;
proxy_pass http://0.0.0.0:8082/;
}
}
@crottolo
Copy link

crottolo commented Mar 17, 2018

server {
listen 80;
server_name server.com;

add_header Strict-Transport-Security max-age=63072000;
#client_max_body_size 200M;

Security features

if ($http_user_agent ~* LWP::Simple|BBBike|wget) {
return 403;
}
if ($http_user_agent ~* msnbot|scrapbot) {
return 403;
}

Traccar Setup

location / {
proxy_set_header Host $host;

proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

proxy_redirect http://0.0.0.0:8082/ /;
proxy_redirect ws://0.0.0.0:8082/api/socket /api/socket;
proxy_pass http://0.0.0.0:8082/;
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;

}
}

add
proxy_read_timeout 86400s;
proxy_send_timeout 86400s;
for error in websocket error in webgui after 60s.

@naderz
Copy link

naderz commented Oct 16, 2018

Did you manage to figure out why is the reason of the timeout after 60s ? is that being triggered even if packets are being sent ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment