Skip to content

Commit

Permalink
essaie du https
Browse files Browse the repository at this point in the history
  • Loading branch information
etienne committed Feb 14, 2024
1 parent b600683 commit 795aeae
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
ansible-galaxy collection install community.docker
echo "[all]" > inventory.ini
echo "my_instance ansible_host=${{secrets.ip_address}} ansible_user=hibo ansible_ssh_private_key_file=./private_key" >> inventory.ini
ansible-playbook -i inventory.ini playbook.yml --extra-vars "MONGO_INITDB_ROOT_USERNAME=${{ secrets.MONGO_INITDB_ROOT_USERNAME }} MONGO_INITDB_ROOT_PASSWORD=${{ secrets.MONGO_INITDB_ROOT_PASSWORD }} MONGO_INITDB_DATABASE=${{ secrets.MONGO_INITDB_DATABASE }} MONGODB_USER=${{ secrets.MONGODB_USER }} MONGODB_USER_PASSWORD=${{ secrets.MONGODB_USER_PASSWORD }} SITE_ADDRESS=${{secrets.ip_address}} NEXT_PUBLIC_BASE_URL=${{ secrets.NEXT_PUBLIC_BASE_URL }} PORT=${{ secrets.PORT }} DEBUG=${{ secrets.DEBUG }}"
ansible-playbook -i inventory.ini playbook.yml --extra-vars "MONGO_INITDB_ROOT_USERNAME=${{ secrets.MONGO_INITDB_ROOT_USERNAME }} MONGO_INITDB_ROOT_PASSWORD=${{ secrets.MONGO_INITDB_ROOT_PASSWORD }} MONGO_INITDB_DATABASE=${{ secrets.MONGO_INITDB_DATABASE }} MONGODB_USER=${{ secrets.MONGODB_USER }} MONGODB_USER_PASSWORD=${{ secrets.MONGODB_USER_PASSWORD }} SITE_ADDRESS=${{secrets.ip_address}} ORIGIN_URL=${{ secrets.ORIGIN_URL }} NEXT_PUBLIC_BASE_URL=${{ secrets.NEXT_PUBLIC_BASE_URL }} PORT=${{ secrets.PORT }} DEBUG=${{ secrets.DEBUG }} JWT_SECRET=${{ secrets.JWT_SECRET }}"
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
ANSIBLE_HOST_KEY_CHECKING: False
Expand Down
8 changes: 4 additions & 4 deletions backend/src/routes/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const server = http.createServer(app);

const io = new Server(server, {
cors: {
origin: "*",
origin: process.env.ORIGIN_URL || "*",
methods: ["GET", "POST", "PUT", "DELETE"],
},
maxHttpBufferSize: 2e7,
Expand Down Expand Up @@ -79,7 +79,7 @@ io.on("connection", (socket) => {
try {
await Room.findByIdAndDelete(roomId);
io.emit("room_deleted", roomId);

console.log(`Room ${roomId} deleted.`);
} catch (error) {
console.error(`Error deleting room ${roomId}: `, error);
Expand Down Expand Up @@ -129,9 +129,9 @@ io.on("connection", (socket) => {
});

// Confirme la jonction à l'utilisateur
socket.emit("room_joined", {roomName: room.name, roomId: roomId});
socket.emit("room_joined", { roomName: room.name, roomId: roomId });
});

socket.on("send_message", async (data) => {
io.emit("receive_message", data);

Expand Down
26 changes: 17 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,24 @@ services:
image: traefik
container_name: traefik
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- --providers.docker=true
- --providers.docker.exposedbydefault=false
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --certificatesresolvers.letsencrypt.acme.email=hibobo@kurama-chat.xyz
- --certificatesresolvers.letsencrypt.acme.storage=acme/acme.json
- --certificatesresolvers.letsencrypt.acme.tlschallenge=true
- --entryPoints.web.http.redirections.entryPoint.to=websecure
- --entryPoints.web.http.redirections.entryPoint.scheme=https
- --entryPoints.web.http.redirections.entrypoint.permanent=true
- --certificatesresolvers.letsencrypt.acme.caserver=https://acme-v02.api.letsencrypt.org/directory
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./volumes/traefik/acme:/acme
- ./volumes/traefik/logs:/logs
networks:
- web

Expand Down Expand Up @@ -49,6 +56,7 @@ services:
- MONGO_INITDB_DATABASE=${MONGO_INITDB_DATABASE}
- MONGODB_USER=${MONGODB_USER}
- MONGODB_USER_PASSWORD=${MONGODB_USER_PASSWORD}
- ORIGIN_URL=${ORIGIN_URL}
- PORT=${PORT}
- DEBUG=${DEBUG}
ports:
Expand All @@ -65,9 +73,9 @@ services:
- ./frontend:/frontend/src
labels:
- "traefik.enable=true"
- "traefik.http.routers.frontend.rule=HostRegexp(`{any:.*}`)"
- "traefik.http.routers.frontend.entrypoints=web,websecure"
- "traefik.http.services.frontend.loadbalancer.server.port=3000"
- traefik.http.routers.whoami.rule=Host(`kurama-chat.com`)
- traefik.http.routers.whoami.entrypoints=websecure
- traefik.http.routers.whoami.tls.certresolver=letsencrypt
networks:
- web
environment:
Expand Down
62 changes: 32 additions & 30 deletions playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@
ignore_errors: true

- block:
- name: Run the equivalent of "apt-get update" as a separate step
apt:
update_cache: true
cache_valid_time: 3600
- name: Update all packages to the latest version
apt:
upgrade: dist
- name: Install Docker dependencies
apt:
name: "{{ item }}"
state: latest
loop:
- apt-transport-https
- ca-certificates
- curl
- gnupg
- lsb-release
- name: Add Docker's official GPG key
shell: sudo rm -f /usr/share/keyrings/docker-archive-keyring.gpg && curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- name: Set up the Docker stable repository
apt_repository:
repo: deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable
- name: Update apt packages
apt:
update_cache: yes
- name: Install Docker
apt:
name: docker-ce
state: latest
- name: Run the equivalent of "apt-get update" as a separate step
apt:
update_cache: true
cache_valid_time: 3600
- name: Update all packages to the latest version
apt:
upgrade: dist
- name: Install Docker dependencies
apt:
name: "{{ item }}"
state: latest
loop:
- apt-transport-https
- ca-certificates
- curl
- gnupg
- lsb-release
- name: Add Docker's official GPG key
shell: sudo rm -f /usr/share/keyrings/docker-archive-keyring.gpg && curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- name: Set up the Docker stable repository
apt_repository:
repo: deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable
- name: Update apt packages
apt:
update_cache: yes
- name: Install Docker
apt:
name: docker-ce
state: latest
when: docker_installed.rc != 0

- name: Check if Python pip is installed
Expand Down Expand Up @@ -126,6 +126,8 @@
NEXT_PUBLIC_BASE_URL=http://{{ SITE_ADDRESS }}:{{ PORT }}/
PORT={{ PORT }}
DEBUG={{ DEBUG }}
ORIGIN_URL={{ ORIGIN_URL }}
JWT_SECRET={{ JWT_SECRET }}
- name: Check if network web exists
command: docker network ls --filter name=^web$ --format={{'.Name'}}
Expand All @@ -137,4 +139,4 @@

- name: Execute docker-compose for Deployment
docker_compose:
project_src: /var/deployment/
project_src: /var/deployment/
19 changes: 19 additions & 0 deletions volumes/traefik/acme/acme.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"letsencrypt": {
"Account": {
"Email": "[email protected]",
"Registration": {
"body": {
"status": "valid",
"contact": [
"mailto:[email protected]"
]
},
"uri": "https://acme-v02.api.letsencrypt.org/acme/acct/1569675727"
},
"PrivateKey": "MIIJKQIBAAKCAgEAxpkBxQhgdt4EpMcNjSJ/f4nNWC+vJxx30A+DVkoUMBrA8RH5mraRj26vzLYGvYcugbmUtKAZFyXGyzM9hhSFu+GU/PjCwVBlR9YF+STfaZ2lUGI1eIhg9J7js5aYGHJbenag4fxCmScfqNlZlaKrn/YoBbUgqRvYTX8lsU9CYviqsy083GqJmupdGoFbHrfGaH1Zv8Aev+3inF313AiTX+6FpbWIEmMHIXET1D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+9bDkNTbpueOhn6B+V3BFeHcPM3KyLZjuU3Uo3QKCAQAmA92lCQU2FYn7V4C65U6P0J6Rtmovjdh1wTUcySSG6MazE0JTJaLX/nuIgCnHPs94jok4+UuHAkVKroo86HH1vnaN6wtA4BVAa7I1lE7NfiwFdl6fUwe4O9QM6PY7sloVCa9K/UehCOArdlHeA0e3p1ebwR+3ew3TIc07mbZdbBoa2sl2Tgb5fz3LIxwoxduvJuv0fYBL95wQ6jCUedQEMzoO6GJGIANi0cvJoY9VoxsEOHcUIoWnr6nWekzOlzT9w8/OQZAETDp3Tqlk2tWF0OQee71+o+GNlz25fJ+VhLgPKmr1gcjV3LtwgsY0veKdWUOIO652cy/cILtujRghAoIBAQCjF5PNNYWrm0RCYz7fL5JpV0paIJ6rXujO1ppRHfUAw2YxtvGfRP9sHMCYv9QjDyuXQqohfh4U2+55ulX7dwHtPc8NKXlrdOehLRtWYOtr9p7DzzGkOAl3kQjV/0l4a1cFD6fCNITYXVRsTHkKYDpzxZuDlEJXzVUOA5YGqKit9lm5oPpUERljKv/cKNaorg9GRfa2yL/ujp91Q28thsXkBvfyLxuYBy4iawWQM1vw37bu37NhQfXgHh6pebpkr7JmHwPcFFWGO29j6gxSlTCmGbwgOWa1qbPbfAE/DtpEiPFm2PRuXD+qkeeSEOrpfZF5YbWeadG1VLbQkQpCQwH/",
"KeyType": "4096"
},
"Certificates": null
}
}

0 comments on commit 795aeae

Please sign in to comment.