FlightAware Discussions

Migrate dump1090-fa to apache

Hopefully this helps some folks, and someone can help with the last issue.

Im migrating dump1090-fa from using lighttpd to apache. Pretty easy I think for a non-heavy linux user.

did the following:
Move the " 88" and “89” dump1090 config files from /etc/lighttpd to /etc/apache2/conf-available
create sym links in /etc/apache2/conf-enabled for same

Modify the 89-dump1090-fa.conf file to alias how apache likes it:

#alias.url += (
Alias /dump1090-fa/data/ /run/dump1090-fa/
Alias /dump1090-fa/ /usr/share/dump1090-fa/html/
#)

#redirect the slash-less URL
#url.redirect += (
Alias ^/dump1090-fa$ /dump1090-fa/
#)

#Listen on port 8080 and serve the map there, too.
#$SERVER[“socket”] == “:8080” {
#alias.url += (
#"/data/" => “/run/dump1090-fa/”,
#"/" => “/usr/share/dump1090-fa/html/”
#)
#}

Note I disabled the 8080 config

My problem is the last block, anyone know how modify the json feed? Apache chokes on it.

#Add CORS header
server.modules += ( “mod_setenv” )
HTTP["url"] =~ "^/dump1090-fa/data/.*\.json" {
setenv.add-response-header = ( “Access-Control-Allow-Origin” => “*” )
}

I don’t mean to be critical, just curious. Why are you doing this? TIA.

Ive stuff I need to run on apache, and dont feel like proxying lighttpd through apache.

Thanks. That makes sense. I also run both Apache and lighttp. But they are on separate RasPi boxes. Apache is internet facing and I proxy over to the PiAware box for the json. All the static stuff I copied to the Apache box. This way I keep a plain vanilla PiAware box. These RasPi boxes are so inexpensive I figured it wasn’t worth the time to try and combine them, and maintain a combined box.

1 Like

Im not the greatest at web stuff. But if you can explain the proxy Ill give it a try. The few threads on here about it weren’t that good at explaining how.

I mis-spoke slightly. The business about moving the static stuff only applies to the Planefinder proxy. For PiAware’s Skyview, it’s a straight proxy. Here’s the code I added to /etc/apache2/sites-enabled/mydefault.conf:

ProxyRequests Off
<Proxy * >
Order deny,allow
Allow from all
< / Proxy > goes here but this forum software won’t display it. remove the spaces.

ProxyPass /adsb/ http://192.168.1.nn/dump1090-fa/
ProxyPassReverse / http://192.168.1.nn/

Of course you need to replace nn with your Piaware’s address, and put a link on your Apache site to “adsb” or whatever you decide to call it.

I don’t know if it is still question to migrate dump1090-fa from lighttpd to apache2 but if somebody wants it, here is a working config for port 81.

1.	Edit /etc/apache2/ports.conf file, and insert line:
Listen 81
2.	If not there, copy „/etc/apache2/mods-available/headers.load” and „/etc/apache2/mods-available/setenvif.load” into „/etc/apache2/mods-enabled” 
3.	Edit „/etc/apache2/sites-enabled/000-default.conf” (or create a new conf file eg. dump1090.conf) with these lines:

<VirtualHost *:81>
        ServerAdmin webmaster@localhost
        DocumentRoot /usr/share/dump1090-fa/html/

        Alias  "/dump1090-fa/data/" "/run/dump1090-fa/"
        Alias  "/data/" "/run/dump1090-fa/"
        Alias  "/dump1090-fa/" "/usr/share/dump1090-fa/html/"
        Alias  "^/dump1090-fa$" "/dump1090-fa/"
        
        SetEnvIf Request_URI "/dump1090-fa/data/.*\.json$" Header set "Access-Control-Allow-Origin" "*"

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
1 Like

Not really working. I got a loading circle and a green loading bar and nothing happens. And in the Firefox inspector i get
http://192.168.0.102:8080/status.json [HTTP/1.1 404 Not Found 2ms]
http://192.168.0.102:8080/data/receiver.json?_= [HTTP/1.1 403 Forbidden 2ms]
htt ://192.168.0.102:8080/upintheair.json [HTTP/1.1 404 Not Found 3ms]

I think, your aliases not working as expected, maybe the aliases are not in the right virtualhost section. So you have to double check your <VirtualHost *:8080> section in your config file if the right aliases exists there.

(I tested in my configuration, and commenting out the aliases resulted the same error. The port 8080 is not the standard Apache2 port, so I am a little confused with your http address. In my configuration the dump10-fa bound to port 81 to avoid any conflict with any existing webpage.

In fact, in any existing configuration only the four alias and the one SetEnvIf… lines are required, and in that case the dump1090 should be accessed on http://[ip address:port]/dump1090-fa/ )

Thanks for your reply.
I double-checked the aliases, but I couldn’t tell a difference.
But it doesn’t matter now because I switched from apache to lighttpd and now everything works as it should on port 8080.

For what it is worth I made it work with apache such as described but in my 000-default.conf I added it as below:

----- snip ------

Alias /dump1090/data /run/dump1090-fa/
Alias /data /run/dump1090-fa/
Alias /dump1090 /usr/share/dump1090-fa/html/
Alias ^/dump1090-fa$ /dump1090-fa/

<Directory “/usr/share/dump1090-fa/html/”>
Options All
AllowOverride All
SetEnvIf Request_URI “/dump1090-fa/data/..json$" Header set “Access-Control-Allow-Origin” "

<Directory “/run/dump1090-fa/”>
Options All
AllowOverride All
SetEnvIf Request_URI “/dump1090-fa/data/..json$" Header set “Access-Control-Allow-Origin” "

----- snip ------

And set the user rights
drwxr-xr-x 8 dump1090 www-data 4096 Jun 10 09:56 html

www-data is the apache owner

This saves me from having to run lighttpd hence load and memory

Chrs

1 Like

I follow the steps posted by raspberrypi.

Now the map (http://192.168.68.128:8080/) loads under Apache. However, I’m getting an error message on the map:

Problem fetching data from dump1090.
AJAX call failed (error: Forbidden). Maybe dump1090 is no longer running?
The displayed map data will be out of date.

I checked under /run/dump1090-fa/ folder, and the json files are all there, so dump1090 is definitely running.

When I tried to access each individual ajax resource, eg (http://192.168.68.128:8080/data/aircraft.json?_=1598081349143), I got this error:

Forbidden

You don’t have permission to access this resource.
Apache/2.4.38 (Raspbian) Server at 192.168.68.128 Port 8080

It seems to me like a permission issue, but I have no idea what folder needs what permission for what user.
Does anyone have any clue? I’m not an expert on raspberry pi or linux or such.

Thank you in advance.

Sounds like SE Linux?

Show the relevant part of your apache config please.

Check the permissions for this directory as well:

ls -ld /run/dump1090-fa/

Normally permissions should be fine … yeah sounds like SE Linux to me.

I’m sorry but what is an SE Linux? I’m running this on a raspberry-pi 3.

I didn’t change anything in apache2.conf.

This is the section in /etc/apache2/sites-enabled/000-default.conf

<VirtualHost *:8080>
ServerAdmin webmaster@localhost
DocumentRoot /usr/share/dump1090-fa/html/
Alias “/dump1090-fa/data/” “/run/dump1090-fa/”
Alias “/data/” “/run/dump1090-fa/”
Alias “/dump1090-fa/” “/usr/share/dump1090-fa/html/”
Alias “^/dump1090-fa$” “/dump1090-fa/”

    <Directory "/usr/share/dump1090-fa/html/">
    Options All
    AllowOverride All
    SetEnvIf Request_URI "/dump1090-fa/data/.*\.json$" Header set "Access-Control-Allow-Origin" "*"
    </Directory>
    <Directory "/run/dump1090-fa/">
    Options All
    AllowOverride All
    SetEnvIf Request_URI "/dump1090-fa/data/.*\.json$" Header set "Access-Control-Allow-Origin" "*"
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

This is the permissions for the dump1090-fa directory:

drwxr-xr-x 2 dump1090 www-data 2500 Aug 22 01:34 /run/dump1090-fa/

This is the permissions for the json files:

-rw-r–r-- 1 dump1090 nogroup 644 Aug 22 01:33 aircraft.json
-rw-r–r-- 1 dump1090 nogroup 822 Aug 22 01:10 history_0.json
-rw-r–r-- 1 dump1090 nogroup 406 Aug 22 01:00 history_100.json
-rw-r–r-- 1 dump1090 nogroup 406 Aug 22 01:01 history_101.json
-rw-r–r-- 1 dump1090 nogroup 199 Aug 22 01:01 history_102.json
-rw-r–r-- 1 dump1090 nogroup 200 Aug 22 01:02 history_103.json
-rw-r–r-- 1 dump1090 nogroup 200 Aug 22 01:02 history_104.json
-rw-r–r-- 1 dump1090 nogroup 200 Aug 22 01:03 history_105.json
-rw-r–r-- 1 dump1090 nogroup 390 Aug 22 01:03 history_106.json
-rw-r–r-- 1 dump1090 nogroup 932 Aug 22 01:04 history_107.json
-rw-r–r-- 1 dump1090 nogroup 932 Aug 22 01:04 history_108.json
-rw-r–r-- 1 dump1090 nogroup 931 Aug 22 01:05 history_109.json

To answer that question, it can be part of the Kernel in a distribution

Try adding:

Require all granted

Apache configuration … -.-
The guide in this thread assumes 2.2, and people probably have apache 2.4 or later now.

Adding “Require all granted” fixed the permission issue!

Thank you so much for your help! I had been scratching my head for several hours before I posted the question.

Sure.

By the way that was only google, i have no clue about apache configuration :wink:

1 Like