'분류 전체보기'에 해당되는 글 194건

wasm 파일에  gzip을 적용하는게 목표 타입 추가

cd /etc/nginx

vi mime.types

application/xspf+xml xspf;
application/zip zip;
application/wasm wasm;

 

nginx.conf  http 부분에서 내용 변환

cd /etc/nginx

vi nginx.conf


        ##
        # Gzip Settings
        ##
        gzip on;
        gzip_disable "msie6";

        gzip_comp_level 6;
        gzip_min_length 500;
        gzip_buffers 16 8k;
        gzip_proxied any;
        gzip_types text/plain text/css text/js text/xml text/javascript application/javascript application/x-javascript application/json application/xml application/rss+xml application/wasm image/svg+xml image/png;


nginx 재부팅

nginx -t

service nginx restart

 

 

gzip on;
gzip_static on;
gzip_disable     "msie6"; # 자동으로 IE6, 5.5를 감지해서 disable한다.
# gzip_disable "MSIE [1-6]\.(?!.*SV1)"; # nginx 0.7 이하에서만
gzip_types application/x-javascript application/javascript application/xml text/javascript application/json text/json text/css text/plain application/xhtml+xml application/rss+xml application/wasm ;

개발자 도구에서 동작 확인

'시스템' 카테고리의 다른 글

s3 권한이 없는 경우  (0) 2022.05.17
프로메테우스 모니터링  (0) 2022.03.30
nginx/1.18.0 (Ubuntu20.04) brotli  (0) 2022.01.11
Gitlab CI react app 배포  (0) 2021.12.31
AWS Amplify 설치  (0) 2021.12.28
블로그 이미지

iesay

,

 

출처 : https://gist.github.com/jivanpal/ce90c0d34ead57bc33d10099278ab423

        https://stackoverflow.com/questions/43862412/why-is-brotli-not-supported-on-http

 

Why is Brotli not supported on HTTP?

I noticed an odd thing where apparently Firefox says it supports Brotli on HTTPS, but not HTTP? As Brotli is like gzip but more efficient, why would it limit it to HTTPS? On a HTTPS tab I see: Acc...

stackoverflow.com

환경 : nginx/1.18.0 (Ubuntu20.04) brotli

        https에서만 동작

 

출처에 있는 셀 스크립트 소스르 vi해서 파일을 만든다.

vi compile-nginx-brotli-modules.sh
chmod 777 compile-nginx-brotli-modules.sh
./compile-nginx-brotli-modules.sh

 

디렉토리 이동후 SO파일을 복사 한다.

cd /root/build/nginx-1.18.0/objs

cp *.so /usr/lib/nginx/modules/

cp *.so /usr/share/nginx/modules

vi /etc/nginx/nginx.conf

최상단에 추가

load_module modules/ngx_http_brotli_filter_module.so;
load_module modules/ngx_http_brotli_static_module.so;

vi /etc/nginx/nginx.conf     http 안에 추가 

brotli on;
brotli_comp_level 6;
brotli_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/wasm application/xml+rss text/javascript image/x-icon image/vnd.microsoft.icon image/bmp image/svg+xml;
brotli_static on;

 

nginx 재부팅 

nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
service nginx restart

 

 

개발자 도구 네트워크 탭에서 확인 할수 있다.

 

적용 전 

 

 

적용 후 

 

 

'시스템' 카테고리의 다른 글

프로메테우스 모니터링  (0) 2022.03.30
nginx/1.18.0 (Ubuntu20.04) gzip  (0) 2022.03.07
Gitlab CI react app 배포  (0) 2021.12.31
AWS Amplify 설치  (0) 2021.12.28
ipfs 사용법  (0) 2021.12.06
블로그 이미지

iesay

,

출처 : https://merrily-code.tistory.com/123

환경 :  AWS LigthSail  8코어 32기가 램 

        Docker 제외하고 nginx에 바로 다이렉트로 deploy

 

 

 

 

 

shell로 등록 

gitlab-runner register -n \
--url https://gitlab.com/ \
--registration-token M9토큰값 \
--description gitlab-runner \
--executor shell

'시스템' 카테고리의 다른 글

nginx/1.18.0 (Ubuntu20.04) gzip  (0) 2022.03.07
nginx/1.18.0 (Ubuntu20.04) brotli  (0) 2022.01.11
AWS Amplify 설치  (0) 2021.12.28
ipfs 사용법  (0) 2021.12.06
gitlab ci Docker 연동(React)  (0) 2021.11.24
블로그 이미지

iesay

,

AWS Amplify 설치

시스템 2021. 12. 28. 15:18

'시스템' 카테고리의 다른 글

nginx/1.18.0 (Ubuntu20.04) brotli  (0) 2022.01.11
Gitlab CI react app 배포  (0) 2021.12.31
ipfs 사용법  (0) 2021.12.06
gitlab ci Docker 연동(React)  (0) 2021.11.24
gitlab CI_SERVER_TLS_CA_FILE: Permission denied  (0) 2021.08.30
블로그 이미지

iesay

,

ipfs 사용법

시스템 2021. 12. 6. 15:47

출처 : https://miiingo.tistory.com/204

https://zooyeonii.tistory.com/7

https://bl.ocks.org/kevin-smets/75f717f22a55ac628744c830c9d6b491

https://simpleaswater.com/ipfs-going-online/

 

#ipfs config show 

{
  "API": {
    "HTTPHeaders": {
      "Server": [
        "go-ipfs/0.4.17"
      ]
    }
  },
  "Addresses": {
    "API": "/ip4/127.0.0.1/tcp/5001",
    "Announce": [],
    "Gateway": "/ip4/127.0.0.1/tcp/8080",
    "NoAnnounce": [],
    "Swarm": [
      "/ip4/0.0.0.0/tcp/4001",
      "/ip6/::/tcp/4001"
    ]
  },

 

외부 접근 가능  

#ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
#ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080


#export LIBP2P_FORCE_PNET=1
ipfs daemon 실행 중인 것을 중지하고 다시 시작한다. 


#ipfs shutdown
#ipfs daemon > ipfs.log &

root@server:~# 06:51:37.225 ERROR p2p-config: tried to create a libp2p node with no Private Network Protector but usage of Private Networks is forced by the enviroment config.go:66
06:51:37.226 ERROR   cmd/ipfs: error from node construction: privnet: private network was not configured but is enforced by the environment daemon.go:332
Error: privnet: private network was not configured but is enforced by the environment

[1]+  Exit 1                  ipfs daemon > ipfs.log
root@server:~#

 

'시스템' 카테고리의 다른 글

Gitlab CI react app 배포  (0) 2021.12.31
AWS Amplify 설치  (0) 2021.12.28
gitlab ci Docker 연동(React)  (0) 2021.11.24
gitlab CI_SERVER_TLS_CA_FILE: Permission denied  (0) 2021.08.30
gitlab ci Docker 연동(nodejs)  (2) 2021.08.23
블로그 이미지

iesay

,

구현 환경  : AWS(ubuntu 20.04) , nodejs

 

출처 : 

[GitLab CI] docker gitlab-runner 등록 및 간단 예제 (tistory.com)

https://www.devopsschool.com/blog/setup-docker-service-to-use-insecurehttp-registry-instead-of-https/

https://hihellloitland.tistory.com/65

https://hihellloitland.tistory.com/63

https://otrodevym.tistory.com/474

https://not-to-be-reset.tistory.com/326

https://gitlab.com/gitlab-org/gitlab-runner/-/issues/5026

 

-  Docker  private registry 설치

우분투 초기 이미지 업데이트 레포 찾음 
apt update

도커 컴포저 설치 
apt install docker-compose

도커 레지스트리 설치 
docker pull registry:latest


레지스트리 이미지 구동
docker run --name local-registry -d --restart=always -p 5000:5000 -v /data/registry:/var/lib/registry/docker/registry/v2 registry:latest





빨간색 처럼 private repo 컨테이너 올라가면  실패 재설치

아래 그림처럼 올라가면 성공

 

 

본인이 구축할 private repo IP주소를 작성하면 됩니다.

push시 https만 허용만 가능하여 이렇게 강제로 설정해 줍니다.

 

vi /etc/docker/daemon.json

{

"insecure-registries" : ["13.125.27.25:5000"]

}

 

도커 재 실행 

service docker restart

 

- 방화벽 오픈 (5000, 8900번)

윈도우 도스창에서
telnet  xxx.xxx.xxx.xxx 5000
제대로 접근 가능한지 확인

##############################################################################

-  Gitlab runnuer 설치

 

mkdir -p /opt/gopath/src/gitlab/

cd /opt/gopath/src/gitlab/

vi docker-compose.gitlab.runner.yml 파일 생성

gitlab-runner:
 container_name: gitlab-runner
 image: 'gitlab/gitlab-runner:latest'
 restart: always
 volumes:
  - '/srv/gitlab-runner/config:/etc/gitlab-runner'
  - '/var/run/docker.sock:/var/run/docker.sock'
  - '/usr/bin/docker:/usr/bin/docker'

 

도커 compose파일 실행 

도커 컴포저 실행

docker-compose -f /opt/gopath/src/gitlab/docker-compose.gitlab.runner.yml up -d

컨테이너 실행 확인 
docker container ls

 

gitlab  새로운 project에 파일 3개 생성

Dockerfile

# This file is a template, and might need editing before it works on your project.
FROM node:10

WORKDIR /usr/src/app

ARG NODE_ENV
ENV NODE_ENV $NODE_ENV

COPY package.json /usr/src/app/
RUN yarn install

COPY . /usr/src/app

# replace this with your application's default port
EXPOSE 3000
CMD [ "yarn", "start" ]

리엑트 프로젝트 샘플

 

package.json

{
  "name": "deployReact",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "0.18.1",
    "enzyme": "^3.8.0",
    "enzyme-adapter-react-16.3": "^1.4.1",
    "moment": "^2.24.0",
    "next": "^8.1.0",
    "node-build-tools": "^0.3.2",
    "node-gyp": "^3.8.0",
    "python2": "^0.0.1",
    "react": "^16.7.0",
    "react-dom": "^16.7.0",
    "react-redux": "^6.0.0",
    "react-router-dom": "^5.0.0",
    "react-scripts": "2.1.7",
    "react-test-renderer": "^16.7.0",
    "react-with-styles": "^3.2.1",
    "recompose": "^0.30.0",
    "redux": "^4.0.1",
    "redux-pack": "^0.1.5",
    "redux-thunk": "^2.3.0",
    "reselect": "^4.0.0",
    "selector-action": "^1.1.1",
    "web-vitals": "^2.1.2"
  },
  "scripts": {
    "dev": "next",
    "predeploy": "yarn build-all",
    "deploy": "firebase deploy",
    "build-all": "yarn ssrbuild && yarn build-firebase",
    "build-firebase": "cd \"./functions\" && yarn --ignore-engines",
    "ssrbuild": "next build",
    "storybook": "start-storybook -p 9001 -c .storybook",
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "mockserver": "json-server --watch --delay 500 --port 4000 mock/create.js",
    "errorserver": "node mock/fake.js",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
 },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "devDependencies": {
    "@babel/core": "7.5.5",
    "@babel/plugin-syntax-object-rest-spread": "^7.2.0",
    "@storybook/addon-actions": "^5.2.6",
    "@storybook/addons": "^5.2.6",
    "@storybook/react": "^5.2.6",
    "aphrodite": "^2.2.3",
    "babel-loader": "^8.0.5",
    "json-server": "^0.14.2",
    "node-sass": "^4.12.0",
    "react-with-styles-interface-aphrodite": "^5.0.1",
    "redux-devtools-extension": "^2.13.8",
    "sass-loader": "^7.1.0",
    "storybook-addon-jsx": "^7.1.13"
  }
}

토큰값 확인 

신용카드 auth도 진행하는데 해외결제 그낭 카드번호만 넣으면 완료

 

 

gitlab-runner 컨테이너에서 등록

아래 보라색 두값만 위 2번에 맞게 쓰시면 되고 Docker 컨테이너 내부 에서 유일하게 진행하는 작업.

그외는 모두 Docker 밖에서 실행

도커 gitlab-runner 컨테이너 실행
docker container exec -it gitlab-runner bash


root@4abec937906f:/# gitlab-runner register -n \
--url https://gitlab.com/ \
--registration-token M9토큰값 \
--description gitlab-runner \
--executor docker \
--docker-image docker:latest \
--docker-volumes /var/run/docker.sock:/var/run/docker.sock

 

Edit를 클릭하여 Tags에  [gitlab-cicd-tag] 작성

 

위에 설정한 tag는 아래 yml파일에서도 사용

리엑트 프로젝트는 포트 3000으로 실행

.gitlab-ci.yml

stages:
  - test
  - build
  - deploy

variables:
  IMAGE_NAME: 13.125.27.25:5000/nodejs-server-test:latest

cache:
  paths:
    - node_modules/
    
test:
  stage: test
  image: node:10
  script:
    - env
    - yarn


build:
  stage: package
  tags:
    - gitlab-cicd-tag
  image: docker:latest
  services:
    - docker:dind
  stage: build
  script:
    - ls -al
    - docker container ls -a
    - docker build . -t $IMAGE_NAME
    - docker push $IMAGE_NAME
    - docker images | grep '13.125.27.25'

deploy:
  stage: deploy
  tags:
    - gitlab-cicd-tag
  image: docker:latest
  services:
    - docker:dind
  script:
    - docker container ls -a
    - docker container rm -f nodejs-server 
    - docker run -d -p 3000:3000 --name nodejs-server --restart always $IMAGE_NAME
    - docker container ls -a

 



 

 

 

 

gitlab 해당 프로젝트에 파일이 push뒤면 ci pipe라인에서 자동으로 실행 됩니다.

서버 사양은 꽤나 높으면 빠를거 같습니다.

'시스템' 카테고리의 다른 글

AWS Amplify 설치  (0) 2021.12.28
ipfs 사용법  (0) 2021.12.06
gitlab CI_SERVER_TLS_CA_FILE: Permission denied  (0) 2021.08.30
gitlab ci Docker 연동(nodejs)  (2) 2021.08.23
Configuring tzdata Dockerfile  (0) 2021.07.27
블로그 이미지

iesay

,

Grafana 기초1

Prometheus 2021. 11. 10. 13:41

테스트 환경 : VirturalBox 6.x   ,  Ubuntu20.04

 

ubuntu 설치시에 Prometheus를 기본으로 추가 하여 설치 하였다.

prometheus.yml 설정파일이 보이고  9090포트가 LISTEN이 된걸 확인 할수 있다.

root@server:/# find ./ -name prometheus.yml
./var/snap/prometheus/53/prometheus.yml
root@server:/#

root@server:/# netstat -an | more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.1:40778         127.0.0.1:9090          ESTABLISHED
tcp        0     64 192.168.0.50:22         192.168.0.28:9862       ESTABLISHED
tcp6       0      0 :::9090                 :::*                    LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 127.0.0.1:9090          127.0.0.1:40778         ESTABLISHED
udp        0      0 127.0.0.53:53           0.0.0.0:*
udp        0      0 192.168.0.50:68         0.0.0.0:*
raw6       0      0 :::58                   :::*                    

 

 

모니터정보를 수집할 Agent를 설치한 모습

 

'Prometheus' 카테고리의 다른 글

신규 설치 error  (0) 2024.04.18
블로그 이미지

iesay

,

DISCORD bot 제작

nodejs 2021. 10. 22. 23:48

DISCORD bot 제작

출처 :  https://mmsesang.tistory.com/19

 

nodejs 버전 14.10 설정

apt-get install build-essential libssl-dev
 


curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
 


source ~/.bashrc

 

nvm install 14.10.0

nvm use v14.10.0

nvm alias default v14.10.0
node --version

 

package.json

{
  "name": "bot",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "discord.js": "^12.3.0"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

기본으로 npm install discord.js 설치한 13버전은 동작하지 않았슴

dependencies    discord버전을 12.3으로 명시해서

npm init

npm install을 하는게 좋음

 

 

index.js

const Discord = require("discord.js");
const config = require("./config.json");
const prefix = "!";


const client = new Discord.Client();


client.on("message", function(message) {
    // message 작성자가 봇이면 그냥 return
    if (message.author.bot) return;
    // message 시작이 prefix가 아니면 return
    if (!message.content.startsWith(prefix)) return;


    const commandBody = message.content.slice(prefix.length);
    const args = commandBody.split(' ');
    const command = args.shift().toLowerCase();
   
    if (command === "ping") {
        message.reply(`pong!`);
    } else if (command === "sum") {
        const numArgs = args.map(x => parseFloat(x));
        const sum = numArgs.reduce((counter, x) => counter += x);
        message.reply(`Sum result: ${sum}`);
    }
});


client.login(config.BOT_TOKEN);


config.json

{
    "BOT_TOKEN": "본인토큰값"
}

실행하기

root@server:~/bot# node index.js

 

!ping   명령어를 치면 

봇이 pong! 으로 응답하고

!sum 1 2 3  입력하면

Sum result : 6 반환한다.

다양한 봇을 작성할수가 있다.

 

 

 

 

 

'nodejs' 카테고리의 다른 글

nodejs so파일  (0) 2021.09.10
MongoError: Cannot use a session that has ended  (0) 2021.07.20
nodejs 버전 업데이트 하기  (0) 2021.07.15
nodemon 설정 방법  (0) 2020.12.09
axios 전송  (0) 2020.12.08
블로그 이미지

iesay

,

nodejs so파일

nodejs 2021. 9. 10. 14:55

출처 : https://github.com/node-ffi/node-ffi

디렉토리 생성

 

root@server:~/ffi-napi# node -v
v12.19.0

 

 

mkdir ffi-napi

cd ffi-napi

npm install ffi-napi

 

 

factorial.c

#include <stdio.h>


int factorial(int max) {
  int i = max;
  int result = 1;

  while (i >= 2) {
    result *= i--;
  }

  return result;
}

int main(void)
{
        printf("%d\n", factorial(6));
        return 0;
}

공유라이브러리 컴파일

gcc -shared -fpic factorial.c -o libfactorial.so

 

factorial.js

var ffi = require('ffi-napi');
var libfactorial = ffi.Library('./libfactorial', {
  'factorial': [ 'uint64', [ 'int' ] ]
})

if (process.argv.length < 3) {
  console.log('Arguments: ' + process.argv[0] + ' ' + process.argv[1] + ' <max>')
  process.exit()
}

var output = libfactorial.factorial(parseInt(process.argv[2]))

console.log('Your output: ' + output) 

 

실행 

root@server:~/ffi-napi# node factorial.js 3
Your output: 6
root@server:~/ffi-napi# node factorial.js 7
Your output: 5040

'nodejs' 카테고리의 다른 글

DISCORD bot 제작  (0) 2021.10.22
MongoError: Cannot use a session that has ended  (0) 2021.07.20
nodejs 버전 업데이트 하기  (0) 2021.07.15
nodemon 설정 방법  (0) 2020.12.09
axios 전송  (0) 2020.12.08
블로그 이미지

iesay

,
# groups gitlab-runner
gitlab-runner : gitlab-runner



# usermod -a -G root gitlab-runner



# groups gitlab-runner
gitlab-runner : gitlab-runner root

 

'시스템' 카테고리의 다른 글

ipfs 사용법  (0) 2021.12.06
gitlab ci Docker 연동(React)  (0) 2021.11.24
gitlab ci Docker 연동(nodejs)  (2) 2021.08.23
Configuring tzdata Dockerfile  (0) 2021.07.27
방화벽 설정  (0) 2020.10.26
블로그 이미지

iesay

,