Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CrazyAdmin/e76f373b2d017227c4a3fa3050803f06 to your computer and use it in GitHub Desktop.
Save CrazyAdmin/e76f373b2d017227c4a3fa3050803f06 to your computer and use it in GitHub Desktop.

Revisions

  1. @Sun1ive Sun1ive revised this gist Jun 13, 2018. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions docker + nginx + nodejs + pm2 + mongo.txt
    Original file line number Diff line number Diff line change
    @@ -50,9 +50,10 @@ services:
    # нужно изменить внешний (первый) порт на открытый например(1337)
    # нужно изменить внутренний (второй) порт на 443 если SSL
    ports:
    - "1337:443"
    - "80:80"
    - "443:443"
    api:
    image: node:latest
    image: node:10
    restart: always
    volumes:
    - ./myapp:/usr/app
  2. @Sun1ive Sun1ive revised this gist Jun 13, 2018. 1 changed file with 32 additions and 17 deletions.
    49 changes: 32 additions & 17 deletions docker + nginx + nodejs + pm2 + mongo.txt
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,39 @@
    # NGINX CONFIG
    server {
    #нжинкс слушает порты и прокисрует на докер контейнер
    listen 80 default_server;
    listen [::]:80 default_server;
    return 301 https://$host$request_uri;
    listen 80 default_server;
    listen [::]:80 default_server;

    return 301 https://$host$request_uri;
    }
    server {
    listen 443 ssl default_server;
    listen [::]:443 ssl default_server;
    ssl on;
    ssl_certificate ssl/example.com.crt;
    ssl_certificate_key ssl/example.com.key;
    server_name example.com;

    root /var/www/example.com;
    index index.html;

    location / {
    proxy_pass http://api:8081;
    }
    listen 443 ssl default_server;
    listen [::]:443 ssl default_server;

    ssl on;
    ssl_certificate ssl/fullchain.pem;
    ssl_certificate_key ssl/privkey.pem;


    root /var/www/example.com;
    index index.html;
    server_name www.sunlive.pro sunlive.pro;

    location / {
    proxy_pass http://app:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_redirect off;

    proxy_buffers 8 32k;
    proxy_buffer_size 64k;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;
    }

    }

    # Docker-compose.yml
  3. @Sun1ive Sun1ive renamed this gist May 14, 2018. 1 changed file with 11 additions and 0 deletions.
    Original file line number Diff line number Diff line change
    @@ -42,6 +42,16 @@ services:
    volumes:
    - ./myapp:/usr/app
    command: /bin/bash -c "cd /usr/app && npm i -g pm2 && npm i && npm start"
    mongoDB:
    image: mongo
    restart: always
    environment:
    MONGO_INITDB_ROOT_USERNAME: root
    MONGO_INITDB_ROOT_PASSWORD: example
    MONGO_INITDB_DATABASE: testdb
    ports:
    - "3001:27017"


    ##### pm2 #####
    #process.yml
    @@ -58,6 +68,7 @@ apps:
    }



    #stop all containers:
    docker kill $(docker ps -q)

  4. @Sun1ive Sun1ive renamed this gist May 14, 2018. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. @Sun1ive Sun1ive revised this gist May 13, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,7 @@ version: '3.2'
    services:
    web:
    image: nginx
    restart: on-failure
    restart: always
    volumes:
    # default.conf
    - ./config:/etc/nginx/conf.d
    @@ -38,6 +38,7 @@ services:
    - "1337:443"
    api:
    image: node:latest
    restart: always
    volumes:
    - ./myapp:/usr/app
    command: /bin/bash -c "cd /usr/app && npm i -g pm2 && npm i && npm start"
  6. @Sun1ive Sun1ive revised this gist May 13, 2018. 1 changed file with 16 additions and 2 deletions.
    18 changes: 16 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ server {
    index index.html;

    location / {
    proxy_pass http://api:3000;
    proxy_pass http://api:8081;
    }
    }

    @@ -40,7 +40,21 @@ services:
    image: node:latest
    volumes:
    - ./myapp:/usr/app
    command: /bin/bash -c "cd /usr/app && npm i && npm start"
    command: /bin/bash -c "cd /usr/app && npm i -g pm2 && npm i && npm start"

    ##### pm2 #####
    #process.yml
    apps:
    - script : './src/index.js'
    name : 'API'
    exec_mode: 'cluster'
    instances: 1
    watch: true (?)

    #package.json
    "scripts": {
    "start": "pm2-runtime process.yml"
    }


    #stop all containers:
  7. @Sun1ive Sun1ive revised this gist May 12, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -29,6 +29,7 @@ services:
    image: nginx
    restart: on-failure
    volumes:
    # default.conf
    - ./config:/etc/nginx/conf.d
    - ./ssl:/etc/nginx/ssl
    # нужно изменить внешний (первый) порт на открытый например(1337)
  8. @Sun1ive Sun1ive revised this gist May 12, 2018. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,6 @@
    # NGINX CONFIG
    server {
    #nginx слушает внутренний порт локальной машины
    #можно тут любой свободный хуярить
    #нжинкс слушает порты и прокисрует на докер контейнер
    listen 80 default_server;
    listen [::]:80 default_server;
    return 301 https://$host$request_uri;
  9. @Sun1ive Sun1ive revised this gist May 10, 2018. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    # NGINX CONFIG
    server {
    #nginx слушает внутренний порт локальной машины
    #можно тут любой свободный хуярить
    listen 80 default_server;
    listen [::]:80 default_server;
    return 301 https://$host$request_uri;
    @@ -30,10 +32,10 @@ services:
    volumes:
    - ./config:/etc/nginx/conf.d
    - ./ssl:/etc/nginx/ssl
    # нужно изменить внешний (первый) порт на открытый
    # нужно изменить внешний (первый) порт на открытый например(1337)
    # нужно изменить внутренний (второй) порт на 443 если SSL
    ports:
    - "80:80"
    - "1337:443"
    api:
    image: node:latest
    volumes:
  10. @Sun1ive Sun1ive revised this gist May 7, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -55,3 +55,4 @@ docker rmi $(docker images -q)
    https://letsencrypt.org/docs/certificates-for-localhost/
    #ssl for domain
    https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04
    https://oxozle.com/2018/01/21/nastrojka-ssl-let-s-encrypt-v-nginx-na-ubuntu
  11. @Sun1ive Sun1ive revised this gist May 7, 2018. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -40,6 +40,16 @@ services:
    - ./myapp:/usr/app
    command: /bin/bash -c "cd /usr/app && npm i && npm start"


    #stop all containers:
    docker kill $(docker ps -q)

    #remove all containers
    docker rm $(docker ps -a -q)

    #remove all docker images
    docker rmi $(docker images -q)

    #ssl
    #ssl for localhost
    https://letsencrypt.org/docs/certificates-for-localhost/
  12. @Sun1ive Sun1ive revised this gist May 2, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -30,7 +30,8 @@ services:
    volumes:
    - ./config:/etc/nginx/conf.d
    - ./ssl:/etc/nginx/ssl
    # тут нужно изменить внешний порт на открытый
    # нужно изменить внешний (первый) порт на открытый
    # нужно изменить внутренний (второй) порт на 443 если SSL
    ports:
    - "80:80"
    api:
  13. @Sun1ive Sun1ive revised this gist May 2, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -30,6 +30,7 @@ services:
    volumes:
    - ./config:/etc/nginx/conf.d
    - ./ssl:/etc/nginx/ssl
    # тут нужно изменить внешний порт на открытый
    ports:
    - "80:80"
    api:
  14. @Sun1ive Sun1ive revised this gist May 2, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,7 @@
    server {
    listen 80 default_server;
    listen [::]:80 default_server;
    return 301 https://$host$request_uri;
    }
    server {
    listen 443 ssl default_server;
  15. @Sun1ive Sun1ive revised this gist May 2, 2018. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,13 @@
    server {
    listen 80 default_server;
    listen [::]:80 default_server;

    }
    server {
    listen 443 ssl default_server;
    listen [::]:443 ssl default_server;
    ssl on;
    ssl_certificate ssl/example.com.crt;
    ssl_certificate_key ssl/example.com.key;
    server_name example.com;

    root /var/www/example.com;
    @@ -22,6 +28,7 @@ services:
    restart: on-failure
    volumes:
    - ./config:/etc/nginx/conf.d
    - ./ssl:/etc/nginx/ssl
    ports:
    - "80:80"
    api:
  16. @Sun1ive Sun1ive revised this gist May 2, 2018. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -28,4 +28,10 @@ services:
    image: node:latest
    volumes:
    - ./myapp:/usr/app
    command: /bin/bash -c "cd /usr/app && npm i && npm start"
    command: /bin/bash -c "cd /usr/app && npm i && npm start"

    #ssl
    #ssl for localhost
    https://letsencrypt.org/docs/certificates-for-localhost/
    #ssl for domain
    https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04
  17. @Sun1ive Sun1ive created this gist Apr 22, 2018.
    31 changes: 31 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    # NGINX CONFIG
    server {
    listen 80 default_server;
    listen [::]:80 default_server;

    server_name example.com;

    root /var/www/example.com;
    index index.html;

    location / {
    proxy_pass http://api:3000;
    }
    }

    # Docker-compose.yml
    version: '3.2'

    services:
    web:
    image: nginx
    restart: on-failure
    volumes:
    - ./config:/etc/nginx/conf.d
    ports:
    - "80:80"
    api:
    image: node:latest
    volumes:
    - ./myapp:/usr/app
    command: /bin/bash -c "cd /usr/app && npm i && npm start"