OSRM: Server not responding - digital-ocean

I am unable to get a valid response from my server (Ubuntu 16.04) at DigitalOcean after installing OSRM succefully. I have followed the instructions here:
https://github.com/Project-OSRM/osrm-backend/wiki/Running-OSRM
When running the following:
osrm-routed netherlands-latest.osrm
I am getting the following output in my console:
[info] starting up engines, v5.18.0
[info] Threads: 2
[info] IP address: 0.0.0.0
[info] IP port: 5000
[info] http 1.1 compression handled by zlib version 1.2.8
[info] Listening on: 0.0.0.0:5000
[info] running and waiting for requests
Now when I try to access my server at port 5000:
http://123.456.789.000:5000/route/v1/driving/13.388860,52.517037;13.385983,52.496891?steps=true
Is not giving me any response (timeout). I tried the actual domain name as well.
I have also tried to setup a reverse proxy. But apache is also not giving me any logs. Note that this is in my config (/etc/apache2/sites-available/000-default.conf):
<VirtualHost *:8080>
ServerName my.domain.nl
ProxyPass / http://localhost:5000
ProxyPassReverse / http://localhost:5000
ProxyRequests Off
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I have also verified that no firewall is running. Any idea what I could be missing here?

Go to your apache2.conf file and then paste the following line:
ProxyPass /osrm http://localhost:5000
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
Then type this command to stop and start your apache2:
sudo service apache2 stop
sudo service apache2 start
After that go to your browser and check the link below:
https://your_server_ip_or_domain_name/osrm/table/v1/driving/13.388860,52.517037;13.385983,52.496891?annotations=distance
This works for me.

Related

Apache Proxy and Daphne : slow connection

I am using Django 3.2.3, Apache and Daphne. Daphne is very slow.
I use Apache like a proxy to send the request to Daphne :
<VirtualHost *:443>
AllowEncodedSlashes On
ServerName mysite.com
ServerAdmin admin#gmail.com
ProxyPass "/" "http://127.0.0.1:8001/"
ProxyPassReverse "/" "http://127.0.0.1:8001/"
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET" env=CORS
Header set Access-Control-Allow-Credentials "false" env=CORS
SSLCertificateFile /etc/letsencrypt/live/****/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/***/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
I launch Daphne with the command :
daphne -p 8001 asgi:application
When I access to my website, the log of Daphne are :
2021-06-04 21:17:17,821 INFO Adding job tentatively -- it will be properly scheduled when the scheduler starts
2021-06-04 21:17:17,865 INFO Added job "my_job" to job store "default"
2021-06-04 21:17:17,866 INFO Scheduler started
2021-06-04 21:17:17,909 INFO Starting server at tcp:port=8001:interface=127.0.0.1
2021-06-04 21:17:17,912 INFO HTTP/2 support not enabled (install the http2 and tls Twisted extras)
2021-06-04 21:17:17,913 INFO Configuring endpoint tcp:port=8001:interface=127.0.0.1
2021-06-04 21:17:17,919 INFO Listening on TCP address 127.0.0.1:8001
127.0.0.1:34650 - - [04/Jun/2021:21:18:07] "GET /fr/" 200 234920209
127.0.0.1:34698 - - [04/Jun/2021:21:18:56] "GET /fr/jsi18n/" 304 -
It's working, I can display the webpage but it's very very slow, 30sec +
I have no idea of what to search, where to search ...
edit ---
Maybe the problem comes from the Apache proxy but I use 127.0.0.1, I do not see why it could be slow. ping 127.0.0.1 is fast.
edit 2 ---
Using dig and nslookup on 127.0.0.1 / localhost / SERVER ADDRESS is fast.
Can you help me maybe with some ideas ? or the solution :)
Thank you
Finally I have found.
The problem was not from apche but from my django code. I do not know exactly because I have a made a lot of tests but I think this is because the redis server was not launch.
Thank you

How to deploy NuxtJs Application on Apache and access it with IP-URL instead of a domain?

Please note, this is my first nuxt-app trying to deploy on a staging server. We have a staging AWS server where many web applications are deployed as follows.
http://0.0.0.0/app1/public (Laravel)
http://0.0.0.0/app2 (static)
http://0.0.0.0/app3/public/api (Lumen)
http://0.0.0.0/app4/public (VueJs Static)
etc
http://0.0.0.0/app5 (Tried NuxtJs Universal SSR) failed
Note: SERVER: AWS instance has Ubuntu 18.04 with apache2
Now I want to deploy NuxtJs Universal Application (SSR), I have studied many articles, tried but failed.
What I have done so far:
Moved my all code to /var/www/html/app5
followed all the steps https://nuxtjs.org/docs/2.x/deployment/deployment-pm2
stuck, what to do next, and don't know how to access it in a browser with IP server.
pm2 list, command gives me the following result.
Progress Update:
I have finally found a new way to configure it on the main IP with virtual host configuration:
<VirtualHost *:80>
ServerName http://0.0.0.0
DocumentRoot /var/www/html/app5
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
My steps to configure NuxtJs app on IP-URL:
Created a new virtual host as above named nuxtjs.conf
a2dissite 000-default.conf, it was pointing to /var/www/html
a2ensite nuxtjs.conf
a2enmod proxy_http and a2enmod proxy
systemctl restart apache2
Yahoo! my main server IP-URL (http://0.0.0.0) was pointed to NuxtJs-application running perfectly :-)
But the problem was my all other websites stopped because they were running with 000-default.conf virtual host.
Please guide, what should be configuration, I don't want to close my all websites, they should be running as I mentioned at the start as http://0.0.0.0/name-of-web. How can I run the NuxtJs application as ip-url/app-name?
After a long time, my question was alone, so I decided to give it a partner with my answer, part a joke I have found the solution, and the following is my finding. Please update it if you have the more appropriate knowledge.
Enabled 81 port via AWS console.
Added following configuration in the nuxt.config.js to run the application on a specific port locally in the server.
server: {
port: 43411
}
Updated virtual host as follows.
NameVirtualHost *:81
<VirtualHost *:81>
ServerName http://0.0.0.0
DocumentRoot /var/www/html/app5
ProxyPass / http://localhost:43411/
ProxyPassReverse / http://localhost:43411/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Now I can access my nuxt-app on an IP URL as follows, along with all other deployed websites on this server.
http://0.0.0.0:81/

Apache throws ERROR 500: Internal Server Error when GET from localhost/internal network

I have a production server with apache and django installed using mod_wsgi.
The django application has a REST API that serves some info when a GET request is sent.
This has always worked fine on the develop server, were we ran django using manage.py in a screen. Now we created a production server with apache running django but this API returns Error 500 when running wget from localhost or other machines in the same network (using 192.168.X.X IP).
Here's the output from wget:
~$ wget localhost:80/someinfo
--2020-04-02 16:26:59-- http://localhost/someinfo
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 500 Internal Server Error
2020-04-02 16:26:59 ERROR 500: Internal Server Error.
It seems that the connection succeeds, so I guess it's not an apache problem. The error comes from the API response.
The error in apache error.log looks like this:
127.0.0.1 - - [02/Apr/2020:14:24:36 +0000] "GET /someinfo HTTP/1.1" 500 799 "-" "Wget/1.19.4 (linux-gnu)"
question: what is the number after 500? Sometimes is 799 and other times is 803.
But if the request is done using the public IP of the server from outside (i.e. from the browser) the API works fine and I see the correct information.
I already checked django's allowed hosts and it was accepting localhost, and the 192.168.X.X IP of the other machine. In the end I left django's settings.py like this:
#ALLOWED_HOSTS = ['localhost', '127.0.0.1', '192.168.1.101']
ALLOWED_HOSTS = ['*']
Note: 192.168.1.101 is the machine that tries to make the GET request.
The final goal of all this is to be able to make a GET request from a python script running in that machine (which already works if django runs via manage.py).
My apache.conf:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
#DocumentRoot /var/www/html
Alias /static /home/myuser/myproject/django/static_root
<Directory /home/myuser/myproject/django/static_root>
Require all granted
</Directory>
<Directory /home/myuser/myproject/django/myproject_django>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess myproject python-home=/home/myuser/env python-path=/home/myuser/myproject/django
WSGIProcessGroup myproject
WSGIScriptAlias / /home/myuser/myproject/django/myproject_django/wsgi.py
</VirtualHost>
I tried running django via manage.py and the wget from localhost works just fine. The problem only appears when django is ran by apache.
I also tried the solution given in this post, but changing the line does not fix the error.
I have some doubts concerning this error:
how does apache run django?
does restarting apache2 service also restart django? (thus, reading again the settings.py)
Is there any other django settings file rather than the one I'm editing?
how can I see django logs? I don't have the console now so I can't see real time prints.
I appreciate a lot any help.
I finally managed to solve it myself.
It turns out wsgi handles requests from localhost or external IPs as different instance groups. So all I had to do is put
WSGIApplicationGroup %{GLOBAL}
in /etc/apache2/sites-available/000-default.conf

Server error with Apache, Gunicorn, and Django

I am getting a server error with trying to reverse proxy to Gunicorn.
My virtual host file looks like this:
<virtualhost *:80>
<Location /myApp>
ProxyPreserveHost On
ProxyPass "http://127.0.0.1:8090/"
ProxyPassReverse "http://127.0.0.1:8090/"
</Location>
</virtualhost>
And I'm running Gunicorn like this from within my Django project directory:
gunicorn -b 127.0.0.1:8090 -w 3 myApp.wsgi
Basically I'm wanting to reverse proxy requests to Gunicorn because I can't use mod_wsgi as it can't be compiled for the version of python I am running on my distro of Linux.
I had to do ProxyPass "/server" "http://127.0.0.1:8005/" to get this kind of thing to work it didn't like passing on the root /

How to enable SSL support using Apache + Fastcgi + Django?

I have written a Django App and I want to enable SSL(Https) support in my deployment. Currently my web application is properly served on port80. This is my setup
I am using Apache as my web server
FastCGI as reverse proxy to serve my web app
I launch my Django app using the following command
/usr/bin/python manage.py runfcgi daemonize=false method=threaded host=127.0.0.1 port=8080
I edited the Apache httpd.conf file accordingly
<VirtualHost _default_:80>
Alias /static /opt/tms/web3/static
#For every request that *doesn't* start with "static", send it
#to Django via fastcgi. The address and port must match the
#arguments that are later passed to Django.
<LocationMatch "^/(?!static)">
ProxyPass fcgi://127.0.0.1:8080/
</LocationMatch>
</VirtualHost>
<VirtualHost _default_:443>
Alias /static /opt/tms/web3/static
#For every request that *doesn't* start with "static", send it
#to Django via fastcgi. The address and port must match the
#arguments that are later passed to Django.
<LocationMatch "^/(?!static)">
ProxyPass fcgi://127.0.0.1:8080/
</LocationMatch>
LogLevel warn
ErrorLog /var/log/web_error_log
LogFormat combined
CustomLog /var/log/web_access_log combined
SSLEngine on
SSLCertificateFile /var/opt/tms/web/conf/webserver.cert.pem
SSLCertificateKeyFile /var/opt/tms/web/conf/webserver.priv.pem
SSLCertificateChainFile /var/opt/tms/web/conf/webserver_chain.cert.pem
SSLOptions +StdEnvVars
SSLProtocol -all +TLSv1 +TLSv1.1 +TLSv1.2
SSLCipherSuite HIGH:-aNULL:-kKRB5:-MD5
FileETag None
</VirtualHost>
and I get this error when I access with https
Unable to make a secure connection to the server. This may be a problem with
the server, or it may be requiring a client authentication certificate that you don't have.
Error code: ERR_SSL_PROTOCOL_ERROR