traccar not redirecting in deidcated url in ubuntu with nginx

suraj shrestha7 years ago

I have configured the nginx configuration file for traccar as :-

server {
listen 80;
server_name *********.com;

location / {
proxy_pass http://127.0.0.1:8082;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
port_in_redirect off;
proxy_connect_timeout 900;
proxy_send_timeout 900;
proxy_read_timeout 900;
send_timeout 900;
}
}

I have all files installed in /opt/traccar folder
as well while hitting the url only the apache2 home page show up even theres no apache in the server .

any help please i want may domain hit to traccar

any suggestion willbe more appreciable and thank you !

Anton Tananaev7 years ago

Obviously if you see Apache homepage it means that you are hitting some Apache server. The issue clearly has nothing to do with Traccar.

imarinkovic7 years ago

So NGNIX is not running, probably because ports conflict with Apache...make sure you stop apache, and then run NGNIX.

suraj shrestha7 years ago

Thanks alot for your kind replies ... I have arranged as according and manage the port 8082 to be redirect via nginx . But while hitting the site only the world map get appears . Can you please guide me on this.

Anton Tananaev7 years ago

What do you expect to see? What is the issue exactly?

suraj shrestha7 years ago

I want the site to redirect to the login page not just the map shows up .

suraj shrestha7 years ago

The problem here seems that in my system app.js file is not working via index.html . In nginx setting I have redirected it to index.html file located in simple folder where by the index.html has to source app.js but it seems that the app.js file not executed properly so the map is only showing up . I need help in those matter . Thank you !!!

Please have a look
http://188.166.242.76:8082/

Anton Tananaev7 years ago

Why are you using simple app if you want to use full one?

suraj shrestha7 years ago

means ?? I couldnot get you ..... full one means ?

Anton Tananaev7 years ago

I'm not sure what you are trying to do, but it seems like complete nonsense to me. First you are trying to set up proxy and then you are talking about redirection and html files. I suggest you find someone with enough technical knowledge to configure nginx for you, if you really need it.

suraj shrestha7 years ago

Thank you very much for your kind suggestion but the proxy didnot work exactly for me so I tried to redirect it to html files to get the working interface instead and that also make nonsense results anyway thanx alot ..

Anton Tananaev7 years ago

You HAVE to use proxy. It's not going to work any other way.

suraj shrestha7 years ago

can you please suggest in above code while using proxy do i need to change anything would be very great help . thank you!

Anton Tananaev7 years ago

I don't know how to set up nginx proxy. I would recommend Apache:

https://www.traccar.org/secure-connection/

imarinkovic7 years ago

This is my working config for haproxy. Please take into account I'm using SSL (from LetsEncrypt):

[user@server ~]$ cat /etc/haproxy/haproxy.cfg 
global
        log                     127.0.0.1    local0
        tune.ssl.default-dh-param 2048

defaults
        log                     global
        option                  httplog
        timeout connect         10s
        timeout client          1m
        timeout server          1m

frontend unsecured
        bind *:80
        mode http
        redirect scheme https code 301

frontend  secured
        bind                    0.0.0.0:443 ssl crt /etc/haproxy/ssl/server.domain.com.pem no-sslv3
        mode                    tcp
        log                     global
        option                  tcplog
        timeout                 client   3600s
        backlog                 4096
        maxconn                 50000
        default_backend         www_backend

backend www_backend
        mode                    tcp
        option                  log-health-checks
        option                  redispatch
        option                  tcplog
        balance                 source
        timeout                 connect   1s
        timeout                 queue     5s
        timeout                 server    3600s
        server                  websocket-001 localhost:8082 check

The following is my past (and working) config file (virtualhost)

        ServerName server.domain.com
        DocumentRoot /var/www/html
        SSLEngine on
        SSLProxyEngine On

        ProxyRequests Off
        <Proxy *>
                Require all granted
        </Proxy>

        ProxyPass /api/socket ws://localhost:8082/api/socket
        ProxyPassReverse /api/socket ws://localhost:8082/api/socket

        ProxyPass / http://localhost:8082/
        ProxyPassReverse / http://localhost:8082/
    
        ProxyPass / http://localhost:5055/
        ProxyPassReverse / http://localhost:5055/


        RewriteEngine on
        RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
                RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
        RewriteRule .* ws://localhost:8082%{REQUEST_URI} [P]

        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateFile /etc/letsencrypt/live/server.domain.com/cert.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/server.domain.com/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateChainFile /etc/letsencrypt/live/server.domain.com/chain.pem

Hope this helps!