Skip to content

viliamjr/microblog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A very simple prototype (proof of concept) of Microservice architecture using Go and Nginx.

The services

There is two webapps, login and blog. The blog app references the user using the session controlled by the login app.

Expected behaviour

The application will be available at http://your-host-name.com/ as if there was only one single webapp.

The source code is organized into a single repository to make easier to visualize the prototype.

Setup

  1. Install Go environment and Nginx server.
  2. And get the source/dependencies using Go:
$ go get \
github.com/viliamjr/microblog \
github.com/go-martini/martini \
github.com/martini-contrib/sessions \
github.com/martini-contrib/render

Run

Start the apps:

  • a login app instance:
$ PORT=3000 go run login.go
  • the first instance of blog app:
$ PORT=3001 go run blog.go
  • optionally, you can start a second instance of blog app:
$ PORT=3002 go run blog.go
  • start nginx with the follow configuration:
upstream loginservice {
    ip_hash;
    server 127.0.0.1:3000;
}

upstream blogservice {
    ## ip_hash;
    server 127.0.0.1:3001;
    server 127.0.0.1:3002 weight=3;
}

server {
    listen       80;
    server_name  your-host-name.com;

    location /blog/ {
        proxy_pass http://blogservice/;
    }

    location / {
        proxy_pass http://loginservice;
    }
}

Remember to define 'your-host-name.com' as a valid hostname at your hosts file.

Have fun!

References:

TODO

  • Change shared variables (keys and directories) to environment variables.
  • Provide some documentation: readme and golang style.

About

A very simple prototype (proof of concept) of Microservice architecture using Go and Nginx.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages