35
loading...
This website collects cookies to deliver better user experience
resource "aws_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
}
resource "aws_subnet" "subnet" {
vpc_id = aws_vpc.vpc.id
cidr_block = "10.0.0.0/24"
}
resource "aws_internet_gateway" "gw" {
vpc_id = aws_vpc.vpc.id
}
resource "aws_default_route_table" "rt" {
default_route_table_id = aws_vpc.vpc.default_route_table_id
}
resource "aws_route" "r" {
route_table_id = aws_default_route_table.rt.id
gateway_id = aws_internet_gateway.gw.id
destination_cidr_block = "0.0.0.0/0"
}
resource "aws_default_security_group" "sg" {
vpc_id = aws_vpc.vpc.id
}
resource "aws_security_group_rule" "i_http" {
type = "ingress"
from_port = 8000
to_port = 8000
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
description = "HTTP"
security_group_id = aws_default_security_group.sg.id
}
resource "aws_security_group_rule" "e_all" {
type = "egress"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
description = "All protocols"
security_group_id = aws_default_security_group.sg.id
}
resource "aws_security_group_rule" "i_ssh" {
type = "ingress"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
description = "SSH"
security_group_id = aws_default_security_group.sg.id
}
resource "aws_instance" "instance" {
ami = "ami-0b3e57ee3b63dd76b"
instance_type = "t2.micro"
subnet_id = aws_subnet.subnet.id
associate_public_ip_address = true
key_name = "plausible"
user_data = file("script.sh")
root_block_device {
volume_size = 8
volume_type = "gp2"
encrypted = true
delete_on_termination = false
}
}
aws ec2 create-key-pair --key-name plausible --query "KeyMaterial" --output text > plausible.pem
.#!/bin/bash
yum update -y
amazon-linux-extras install -y docker
service docker start
usermod -a -G docker ec2-user
chkconfig docker on
curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
reboot
$ curl -L https://github.com/plausible/hosting/archive/master.tar.gz | tar xz
$ cd hosting-master
plausible-conf.env
:[email protected]
ADMIN_USER_NAME=XXX
ADMIN_USER_PWD=XXX
BASE_URL=http://1.2.3.4:8000 = l'adresse IP publique de votre instance EC2
SECRET_KEY_BASE=XXX = une clé secrete aléatoire en base64
SMTP_HOST_ADDR=smtp.gmail.com
SMTP_HOST_PORT=465
[email protected]
SMTP_USER_PWD=XXX = votre mot de passe d'application
SMTP_HOST_SSL_ENABLED=true
docker-compose up -d
.http://1.2.3.4:8000
dans notre navigateur préféré et voir la page d'authentification de Plausible. Une fois l'enregistrement terminé, nous devrions avoir le script à rajouter dans le tag head
de notre site pour commencer à mesurer le nombre de vues._document.js
:class MyDocument extends Document {
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx)
return { ...initialProps }
}
render() {
return (
<Html>
<Head>
<script async defer data-domain="example.com" src="http://1.2.3.4:8000/js/plausible.js" />
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
}
http://1.2.3.4:8000
et voir les vues s'accumuler.