Starting a project – the open source way

Standard

You should start/build your project in a way where anyone can help you build it or evolve your work.

What’s the purpose of building something on your own when you can build it faster and in a more efficient way with others?

Nowadays we have all the tools and resources we need in order to start our own project. Stack overflow, github, instructables and hackaday are only a few of the available resources/tools which will help you build the most challenging hardware or software project.

But how we engage more people in our building process in order to achieve great things together?

Continue reading

Running multiple containers mapped in different domains – the discourse example

Standard

 

“Do you want to have multiple docker containers in one server running different services, all mapped in different domain names and discourse to be one of them?”

The idea

This is another blog post coming directly from TechMinistry, Thessaloniki’s local hackerspace.

It’s the time of the year where we are brainstorming about the redesign of our website. We want to add some visibility in our hackerspace’s activities and promote participation within the city’s online community.

So we decided to give Discourse a try to in order to explore all of its features and especially its API.

Unfortunately we didn’t have a spare server to host it so we had to install it in a new docker container since our website already exist in another one.

 

The problem

Our problem was how to test discourse while there was another docker container listening to the same port, 80.

Hint: “nginx reverse proxy”.

After a lot of “ducking” we found that you can set up an nginx reverse proxy server outside the 2 containers in order to handle the requests.

Configuring NGINX

In your server (NOT in any of the containers) you need to create a configuration file and put it inside /etc/nginx/conf.d .

sudo nano /etc/nginx/conf.d/default.conf

The file name doesn’t really matter but inside the it you need to paste the contents of this file.

As you can see in the configuration file, there are two different “apps” (you can change their names if you like) which each one is pointing to a different port in the localhost.

upstream app-a {
server 127.0.0.1:2121;
}

upstream app-b {
server 127.0.0.1:2020;
}

Nginx will forward traffic to these ports, depending on which app you are trying to access.

server {
server_name techministry.gr www.techministry.gr;

location / {
proxy_pass         http://app-a;
proxy_redirect     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;
proxy_set_header   X-Forwarded-Host $server_name;

}
}

At this part we are making clear to nginx that the requests for the techministry.gr URL belong to the app-a and should be forwarded to the relevant port. The same for the other app.

Now we only need to update the nginx process and start the containers. In order for these changes to take affect without restarting nginx you can use the following command:

sudo nginx -s reload

 

Configuring a simple docker container

Let’s run the website container:

docker run –name website -p 2121:80 -t -i -d techministry

Now the website container will forward the traffic that receives from external port 2121 to internal port 80.

Configuring Discourse for the nginx reverse proxy

For making a similar configuration for the discourse container we will need to edit it’s configuration file. We are assuming that you have already followed the Discourse installation guide and you are ready to launch it. Before launching it you need to go back to the app.yml file and change the EXPOSE port to 2020.

nano containers/app.yml

and change the “## which TCP/IP ports should this container expose?” line to:

expose:
– “2020:80″   # fwd host port 80   to container port 80 (http)
– “2222:22″ # fwd host port 2222 to container port 22 (ssh)

Then you follow the discourse installation guide for building the image and running it.

When the installation is complete and the container is up and running you can visit your fresh discourse installation by simply accessing the domain name you reserved in the nginx configuration file which in that case is http://betatechministry.gr.

You can also access the container using your server’s IP followed by the container port – in that case 78.155.69.90:2020.

Conclusion

Following this technique you can have multiple docker containers running different services, all mapped in different domain names.
Pretty awesome, right?

I want to give a special credit  to my friend and TechMinistry’s member Alexandros who dedicated a lot of his free time for this.

Network access issue with OpenWRT and Linksys NSLU2

Standard

Yesterday I remembered that I have a Linksys NSLU2 device somewhere forgotten in a box.

Linksys NSLU2 is small Linux device which connects USB hard drives with the network transforming them in to network drives. It comes with a simple Linksys’ firmware for performing only basic operations and changing some options. Although the device has an ARMv7 CPU which supports a lot of Linux ARM operating systems such as Debian and OpenWRT. You can explorer all the available operating systems available for NSLU2 at NSLU2-Linux’s home page.

My idea was to use NSLU2 as a simple home samba server nothing more nothing less. That’s why I choose to install OpenWRT (installation guide available here) which is light with an operational web interface where you can perform almost every administration operation you want.

After OpenWRT installation I faced two problems:

1. Couldn’t locate the device’s IP

2. The device didn’t has DNS

The first problem was really easy to solve. OpenWRT is a small Linux operating system mainly for routers. That’s why after the installation, OpenWRT has a static IP which is 192.168.1.1 which is the most common IP address for routers.

Now, if you try to plug the OpenWRT device in the network where there is another device or router present with the same IP (192.168.1.1), then you have a problem. You have to change your device’s IP and let the OpenWRT device take 192.168.1.1.

 

The second problem was a little bit tricky. In the first time I thought that the NSLU2 didn’t have internet connections because I couldn’t event ping outside the network. Through OpenWRT’s web interface I visited the Network->Interfaces->Lan page where I was able to add the network’s gateway where for me is 192.168.1.1 (my router’s address). Unfortunately my problem was still the same. Suddenly I realized that I couldn’t ping because there wasn’t a DNS server.

Through Network->Interfaces->Lan page I added a DNS server field with the value 192.168.1.1. That’s right, I added my router’s IP address for DNS Server. Every other IP I tried to add was breaking down my DHCP server.

 

Now I have a fully operational NSLU2 device with OpenWRT installed!

Enjoy 🙂

WebApplications: Enable Geolocation in an Android WebView

Standard

Recently I got amazed by the wonderful world of Web Applications!

It is an amazing world where your application can be run in multiple platforms such as Android, Windows Mobile, iOS and generally every platform/operating system which supports HTML5.

A handy and really useful step by step guide can be found at Mozilla Developer Network.

So tonight I decided to build my first cross platform web application which involves geolocation and google maps API. After I succeed building and running my webapp on Firefox it was time to port it in Android. Generally Anrdoid users think that if the software is not in Play Store (android market) this is not an Application! So I had to create a simple Android application where I had to include only a WebView loading my app’s url.

Simple enough, don’t you think?

Wrong!

The past few hours I am trying to figure out how to enable geolocation in WebView with out any luck! Every guide, question, blog post regarding geolocation and WebView was always missing something.

Finally after a lot of search I found David Chandler’s detailed and fully operational example which saved my night!

There is no need to republish the hole blog post here so take your time and enjoy his beautiful work.

Enjoy 🙂

 

 

 

Greek Coding Camp – Counting days

Standard

The Greek Coding Camp 09 is counting days and the signed up projects are up to 9. All of them are and will be very useful for the Greek foss users. We have projects for translators, FreeBSD users, Linux Users, programmers and generally all free & open source hackers.

If you are a Greek hacker and you still thinking about attending to the camp don’t give a second thought! Just sign up and join us. Cold beers and hot girls are waiting for you.

Shell implement of Game of Life

Standard

The Game of Life is a cellular automaton devised by the British mathematician John Horton Conway in 1970. It is the best-known example of a cellular automaton. The “game” is actually a zero-player game, meaning that its evolution is determined by its initial state, needing no input from human players. One interacts with the Game of Life by creating an initial configuration and observing how it evolves.

Στο μάθημα “Λειτουργικά Συστήματα 2” στο τρίτο εξάμηνο της σχολής μου, μας ζητήθηκε να επιλέξουμε ένα απο τα είκοσι διαθέσιμα project και να τα υλοποιήσουμε σε περιβάλλον κελύφους Linux. Με το που διάβασα τις εκφωνήσεις αμέσως κατέληξα στο project 16 το οποίο είχε θέμα την υλοποίηση του γνωστού μας “Game of Life” σε περιβάλλον κελύφους Linux. Μετά από λίγες μέρες ανάπτυξης τελικά κάτάφερα να το υλοποιήσω επιτυχώς. Σήμερα εξέταστικα στο project και βαθμολογήθηκα με άριστα :D. Παρακάτω σας παραθέτω το pdf του project το οποίο περιέχει πλήρη ανάλυση του project και του κώδικα. Επίσης παραθέτω και το αρχείο πηγαίου κώδικα σχολιασμένο στα Ελληνικά.

Game of life – Analysis

Game of life – Source Code

Περισσότερες πληροφορίες:

http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life

http://www.bitstorm.org/gameoflife/

http://tldp.org/LDP/abs/html/