Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added aws server setup #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Public analytics as a Node.js microservice, no sysadmin experience required.

[![Build Status](https://travis-ci.org/mxstbr/micro-analytics.svg?branch=master)](https://travis-ci.org/mxstbr/micro-analytics)
[![Build Status](https://travis-ci.org/micro-analytics/micro-analytics.svg?branch=master)](https://travis-ci.org/micro-analytics/micro-analytics)

A tiny analytics server with ~100 lines of code, easy to run and hack around on. It does one thing, and it does it well: count the views of something and making the views publicly accessible via an API.

Expand Down
60 changes: 60 additions & 0 deletions server-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,63 @@ server {
```

(note that I have no idea what I'm doing here, this was copied from [this tutorial](https://www.digitalocean.com/community/tutorials/how-to-configure-nginx-as-a-reverse-proxy-for-apache))


## Deploying on AWS (Linux AMI)
To connect to your ec2 instance run (in gitbash):
`ssh -i ./path/to/key.pem [email protected]`
key.pem is the key generated when you create an instance.
xx.xx.xx.xx is the your public ip

Once connnected to ec2 instance install nodejs
Add nodejs yum repo and build tools

`sudo yum install -y gcc-c++ make`
`sudo curl -sL https://rpm.nodesource.com/setup_6.x | sudo -E bash -`
### Installing nodejs
`sudo yum install nodejs`

check version of nodejs and npm
```
node -v
npm -v
```
#### Installing nginx
`sudo yum install nginx`
Now, make the following changes to /etc/nginx/nginx.conf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could refer to the nginx section above?

`sudo vi /etc/nginx/nginx.conf`
```nginx
server {
listen 80;
server_name yourPublicDNS.com;

location ~^.*$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://localhost:3000;
}
}
```
#### Start nginx server
```
sudo service nginx start
sudo service nginx status
```
#### Installing micro-analytics-cli
```
npm install micro-analytics-cli -g
micro-analytics
```
##### Important: enable port 80 on your ec2 instance

* Go to aws.amazon.com, Select ec2 and go to running instances
* On left side navigation menu go to Network & Security > Security groups
* click on the instance for which the port is to be enabled.
* click on inbound tab and click edit. Now in the pop up Add Rule and select http
* save


Now visit the public DNS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we swap DNS with domain in this section?

try to visit some url like www.yourDNS.com/something
If you only specify the public DNS like www.yourDNS.com u will get the message: please include a path to a page