traccar not redirecting in deidcated url in ubuntu with nginx

suraj shrestha7 years ago

thanks imarinkovic thanx but can you please guide me in nginx .. i want to try for last once in nginx then i will go for apache ...

suraj shrestha7 years ago
server {
  
  listen 80;
  server_name traccar;
  
  #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/;
  }   
}

this configuration worked for me in local but not in cloud .....

imarinkovic7 years ago

Did you tried with

proxy_redirect http://127.0.0.1:8082/ /;
proxy_redirect ws://127.0.0.1:8082/api/socket /api/socket;
proxy_pass http://127.0.0.1:8082/;

How about SELINUX or Firewall in use?

suraj shrestha7 years ago

I have use the above code too but didnot worked . I have iptable acceptance for 8082 port . any sites hosted in the server are working but this one still not working .any suggestions please