From 4511d0be1e1a02476565eb89b1584519a39130a0 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Tue, 1 Feb 2022 12:13:35 +0330 Subject: [PATCH 01/22] Add restart policy --- docker-compose.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 0e3b072..082e848 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,9 @@ services: - www:/data/www networks: - default + deploy: + restart_policy: + condition: on-failure volumes: www: external: false From f49cb47926e13a28854b69d85aa7cfc6b9c50951 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Tue, 8 Feb 2022 11:30:26 +0330 Subject: [PATCH 02/22] Add GitHub workflows and Jenkins config for CI/CD --- .github/workflows/dev.yml | 17 ++++++++++++++ .github/workflows/main.yml | 17 ++++++++++++++ Jenkinsfile | 48 ++++++++++++++++++++++++++++++++++++++ dev.Jenkinsfile | 48 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 130 insertions(+) create mode 100644 .github/workflows/dev.yml create mode 100644 .github/workflows/main.yml create mode 100644 Jenkinsfile create mode 100644 dev.Jenkinsfile diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml new file mode 100644 index 0000000..1f79d9c --- /dev/null +++ b/.github/workflows/dev.yml @@ -0,0 +1,17 @@ +name: Deploy OPEX-Nginx - Dev +on: + push: + branches: + - dev +jobs: + jenkinsJob: + name: Build OPEX-Nginx new dev version + runs-on: ubuntu-latest + steps: + - name: Trigger opex-nginx-dev on jenkins + uses: appleboy/jenkins-action@master + with: + url: ${{ secrets.JENKINS_URL }} + user: ${{ secrets.JENKINS_USER }} + token: ${{ secrets.JENKINS_TOKEN }} + job: "opex-nginx-dev" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..ae64f05 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,17 @@ +name: Deploy OPEX-Nginx - Demo +on: + push: + branches: + - main +jobs: + jenkinsJob: + name: Deploy OPEX-Nginx new demo version + runs-on: ubuntu-latest + steps: + - name: Trigger opex-nginx-demo on jenkins + uses: appleboy/jenkins-action@master + with: + url: ${{ secrets.JENKINS_URL }} + user: ${{ secrets.JENKINS_USER }} + token: ${{ secrets.JENKINS_TOKEN }} + job: "opex-nginx-demo" diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..8c4edb1 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,48 @@ +pipeline { + agent any + + stages('Deploy') { + stage('Deliver') { + environment { + COMPOSE_PROJECT_NAME = 'demo-core' + DEFAULT_NETWORK_NAME = 'demo-opex' + } + steps { + sh 'docker-compose up -d --build --remove-orphans' + sh 'docker image prune -f' + sh 'docker network prune -f' + } + } + } + + post { + always { + echo 'One way or another, I have finished' + } + success { + echo ':)' + setBuildStatus(":)", "SUCCESS") + } + unstable { + echo ':/' + setBuildStatus(":/", "UNSTABLE") + } + failure { + echo ':(' + setBuildStatus(":(", "FAILURE") + } + changed { + echo 'Things were different before...' + } + } +} + +void setBuildStatus(String message, String state) { + step([ + $class : "GitHubCommitStatusSetter", + reposSource : [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/opexdev/OPEX-Nginx"], + contextSource : [$class: "ManuallyEnteredCommitContextSource", context: "ci/jenkins/build-status"], + errorHandlers : [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]], + statusResultSource: [$class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]]] + ]) +} diff --git a/dev.Jenkinsfile b/dev.Jenkinsfile new file mode 100644 index 0000000..6c3bba3 --- /dev/null +++ b/dev.Jenkinsfile @@ -0,0 +1,48 @@ +pipeline { + agent any + + stages('Deploy') { + stage('Deliver') { + environment { + COMPOSE_PROJECT_NAME = 'dev-core' + DEFAULT_NETWORK_NAME = 'dev-opex' + } + steps { + sh 'docker-compose up -d --build --remove-orphans' + sh 'docker image prune -f' + sh 'docker network prune -f' + } + } + } + + post { + always { + echo 'One way or another, I have finished' + } + success { + echo ':)' + setBuildStatus(":)", "SUCCESS") + } + unstable { + echo ':/' + setBuildStatus(":/", "UNSTABLE") + } + failure { + echo ':(' + setBuildStatus(":(", "FAILURE") + } + changed { + echo 'Things were different before...' + } + } +} + +void setBuildStatus(String message, String state) { + step([ + $class : "GitHubCommitStatusSetter", + reposSource : [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/opexdev/OPEX-Nginx"], + contextSource : [$class: "ManuallyEnteredCommitContextSource", context: "ci/jenkins/build-status"], + errorHandlers : [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]], + statusResultSource: [$class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]]] + ]) +} From 5dadf4e84cf73689eb763b0ddfe70c1ece650a91 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Tue, 8 Feb 2022 11:31:33 +0330 Subject: [PATCH 03/22] Fix exposed port issue --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 082e848..e89a234 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,7 +3,7 @@ services: nginx: build: . ports: - - '127.0.0.1:80:80' + - '80:80' volumes: - www:/data/www networks: From 0c311987636679300cf8053841c664bce1c6fd12 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Tue, 8 Feb 2022 11:47:30 +0330 Subject: [PATCH 04/22] Fix Jenkins config --- Jenkinsfile | 2 +- dev.Jenkinsfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8c4edb1..be1bc22 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ pipeline { stages('Deploy') { stage('Deliver') { environment { - COMPOSE_PROJECT_NAME = 'demo-core' + COMPOSE_PROJECT_NAME = 'demo-nginx' DEFAULT_NETWORK_NAME = 'demo-opex' } steps { diff --git a/dev.Jenkinsfile b/dev.Jenkinsfile index 6c3bba3..a1ee6e0 100644 --- a/dev.Jenkinsfile +++ b/dev.Jenkinsfile @@ -4,7 +4,7 @@ pipeline { stages('Deploy') { stage('Deliver') { environment { - COMPOSE_PROJECT_NAME = 'dev-core' + COMPOSE_PROJECT_NAME = 'dev-nginx' DEFAULT_NETWORK_NAME = 'dev-opex' } steps { From 73ebfb8a2c67350aca9b47df1281f2edc9175681 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Tue, 8 Feb 2022 12:30:03 +0330 Subject: [PATCH 05/22] Add web-app server to nginx.conf --- nginx.conf | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/nginx.conf b/nginx.conf index 4f1380e..55656ac 100644 --- a/nginx.conf +++ b/nginx.conf @@ -31,6 +31,10 @@ http { server websocket:8080; } + upstream docker-web-app { + server app:80; + } + proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -104,4 +108,13 @@ http { rewrite ^/binance/(.*)$ /$1 break; } } + + server { + server_name opex.dev; + + location /demo { + proxy_pass http://docker-web-app; + rewrite ^/demo/(.*)$ /$1 break; + } + } } From 0be8afa68aceb8c0e26f360951a5e5b09fd5a607 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Tue, 8 Feb 2022 12:32:48 +0330 Subject: [PATCH 06/22] Separate ports on dev environment --- dev.Jenkinsfile | 2 +- docker-compose.dev.yml | 5 +++++ docker-compose.override.yml | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 docker-compose.dev.yml create mode 100644 docker-compose.override.yml diff --git a/dev.Jenkinsfile b/dev.Jenkinsfile index a1ee6e0..d85d169 100644 --- a/dev.Jenkinsfile +++ b/dev.Jenkinsfile @@ -8,7 +8,7 @@ pipeline { DEFAULT_NETWORK_NAME = 'dev-opex' } steps { - sh 'docker-compose up -d --build --remove-orphans' + sh 'docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build --remove-orphans' sh 'docker image prune -f' sh 'docker network prune -f' } diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml new file mode 100644 index 0000000..238e59f --- /dev/null +++ b/docker-compose.dev.yml @@ -0,0 +1,5 @@ +version: '3.8' +services: + nginx: + ports: + - '8080:80' \ No newline at end of file diff --git a/docker-compose.override.yml b/docker-compose.override.yml new file mode 100644 index 0000000..d244d25 --- /dev/null +++ b/docker-compose.override.yml @@ -0,0 +1,5 @@ +version: '3.8' +services: + nginx: + ports: + - '80:80' \ No newline at end of file From b3942d4465dd314e726013328a3e075a388ed854 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Tue, 8 Feb 2022 12:36:59 +0330 Subject: [PATCH 07/22] Change dev environment port number --- docker-compose.dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 238e59f..e1709a8 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -2,4 +2,4 @@ version: '3.8' services: nginx: ports: - - '8080:80' \ No newline at end of file + - '8088:80' \ No newline at end of file From ee2e745e06eea61ec9608940b26d3b088d1a98d9 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Tue, 8 Feb 2022 12:38:33 +0330 Subject: [PATCH 08/22] Update web-app server name --- nginx.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nginx.conf b/nginx.conf index 55656ac..498c0b6 100644 --- a/nginx.conf +++ b/nginx.conf @@ -110,11 +110,11 @@ http { } server { - server_name opex.dev; + listen 80; location /demo { proxy_pass http://docker-web-app; - rewrite ^/demo/(.*)$ /$1 break; + rewrite ^/demo(.*)$ $1 break; } } } From d7451cc3de07c4ae1cc0bccf508b4d61cb91ffc3 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Tue, 8 Feb 2022 13:03:16 +0330 Subject: [PATCH 09/22] Update web-app server name --- nginx.conf | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/nginx.conf b/nginx.conf index 498c0b6..fd86309 100644 --- a/nginx.conf +++ b/nginx.conf @@ -5,6 +5,7 @@ events { } http { + include /etc/nginx/mime.types; sendfile on; upstream docker-wallet { @@ -40,6 +41,13 @@ http { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; + server { + location /demo { + proxy_pass http://docker-web-app; + rewrite ^/demo(.*)$ /$1 break; + } + } + server { server_name api.opex.dev; @@ -108,13 +116,4 @@ http { rewrite ^/binance/(.*)$ /$1 break; } } - - server { - listen 80; - - location /demo { - proxy_pass http://docker-web-app; - rewrite ^/demo(.*)$ $1 break; - } - } } From 85bfb8395c5652b28051745246666872a9682f6d Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Tue, 8 Feb 2022 18:42:17 +0330 Subject: [PATCH 10/22] Remove wrong exposed port --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index e89a234..fd64b91 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,8 +2,6 @@ version: '3.8' services: nginx: build: . - ports: - - '80:80' volumes: - www:/data/www networks: From e94a25b0350810ddad3c1ea3408f7175dfa18a01 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Tue, 8 Feb 2022 18:44:52 +0330 Subject: [PATCH 11/22] Fix static file serving --- nginx.conf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nginx.conf b/nginx.conf index fd86309..554feba 100644 --- a/nginx.conf +++ b/nginx.conf @@ -44,7 +44,11 @@ http { server { location /demo { proxy_pass http://docker-web-app; - rewrite ^/demo(.*)$ /$1 break; + rewrite ^/demo(.*)$ / break; + } + + location / { + proxy_pass http://docker-web-app; } } From 10c0a2548eb309e2a92117f8fe14d146baab9f4b Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Wed, 9 Feb 2022 13:46:55 +0330 Subject: [PATCH 12/22] Add payment gateway to nginx.conf --- nginx.conf | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nginx.conf b/nginx.conf index 554feba..a344b04 100644 --- a/nginx.conf +++ b/nginx.conf @@ -36,6 +36,10 @@ http { server app:80; } + upstream docker-ipg { + server payment:9995; + } + proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -104,6 +108,11 @@ http { rewrite ^/stream/(.*)$ /$1 break; } + location /ipg { + proxy_pass http://docker-ipg; + rewrite ^/ipg/(.*)$ /$1 break; + } + location /api { proxy_pass http://docker-api; rewrite ^/api/(.*)$ /$1 break; From 53a31bacb05dd1a53a3441ff5ac5fc1fb8ef9226 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Wed, 9 Feb 2022 16:18:41 +0330 Subject: [PATCH 13/22] Add server_name to front-end server block --- docker-compose.dev.yml | 2 +- nginx.conf | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index e1709a8..2097b7a 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -2,4 +2,4 @@ version: '3.8' services: nginx: ports: - - '8088:80' \ No newline at end of file + - '8880:80' \ No newline at end of file diff --git a/nginx.conf b/nginx.conf index a344b04..efa2e70 100644 --- a/nginx.conf +++ b/nginx.conf @@ -36,9 +36,9 @@ http { server app:80; } - upstream docker-ipg { - server payment:9995; - } +# upstream docker-ipg { +# server payment:9995; +# } proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -46,10 +46,8 @@ http { proxy_set_header X-Forwarded-Host $server_name; server { - location /demo { - proxy_pass http://docker-web-app; - rewrite ^/demo(.*)$ / break; - } + server_name demo.opex.dev; + server_name demo.opex.dev:8088; location / { proxy_pass http://docker-web-app; @@ -58,6 +56,7 @@ http { server { server_name api.opex.dev; + server_name api.opex.dev:8088; more_set_headers 'Access-Control-Allow-Origin: *'; more_set_headers 'Access-Control-Allow-Headers: *'; @@ -108,10 +107,10 @@ http { rewrite ^/stream/(.*)$ /$1 break; } - location /ipg { - proxy_pass http://docker-ipg; - rewrite ^/ipg/(.*)$ /$1 break; - } +# location /ipg { +# proxy_pass http://docker-ipg; +# rewrite ^/ipg/(.*)$ /$1 break; +# } location /api { proxy_pass http://docker-api; From 1074a0cbf269ab2aa0344dbeacc53bcb3516cf0d Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Sat, 12 Feb 2022 10:15:38 +0330 Subject: [PATCH 14/22] Add https config --- docker-compose.dev.yml | 2 +- nginx.conf | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 2097b7a..d244d25 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -2,4 +2,4 @@ version: '3.8' services: nginx: ports: - - '8880:80' \ No newline at end of file + - '80:80' \ No newline at end of file diff --git a/nginx.conf b/nginx.conf index efa2e70..3688eb2 100644 --- a/nginx.conf +++ b/nginx.conf @@ -46,8 +46,10 @@ http { proxy_set_header X-Forwarded-Host $server_name; server { + listen 80; + listen [::]:80; + server_name demo.opex.dev; - server_name demo.opex.dev:8088; location / { proxy_pass http://docker-web-app; @@ -55,8 +57,10 @@ http { } server { + listen 80; + listen [::]:80; + server_name api.opex.dev; - server_name api.opex.dev:8088; more_set_headers 'Access-Control-Allow-Origin: *'; more_set_headers 'Access-Control-Allow-Headers: *'; From 7207c921f3442e17438eb7b376cdfaf6b4ee1e9c Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Sat, 12 Feb 2022 12:56:55 +0330 Subject: [PATCH 15/22] Enable ipg proxy --- nginx.conf | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/nginx.conf b/nginx.conf index 3688eb2..3d1ce56 100644 --- a/nginx.conf +++ b/nginx.conf @@ -36,9 +36,9 @@ http { server app:80; } -# upstream docker-ipg { -# server payment:9995; -# } + upstream docker-ipg { + server payment:9995; + } proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -111,10 +111,10 @@ http { rewrite ^/stream/(.*)$ /$1 break; } -# location /ipg { -# proxy_pass http://docker-ipg; -# rewrite ^/ipg/(.*)$ /$1 break; -# } + location /ipg { + proxy_pass http://docker-ipg; + rewrite ^/ipg/(.*)$ /$1 break; + } location /api { proxy_pass http://docker-api; From 52f411f66bcef954be74e31b12e745f68e0cc005 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Sat, 12 Feb 2022 16:18:38 +0330 Subject: [PATCH 16/22] Ignore certificate files --- .gitignore | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 55fbb54..35542da 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ # IntelliJ -.idea/ \ No newline at end of file +.idea/ + +# Certificate +*.pem +*.crt +*.der \ No newline at end of file From 2dfa91dd0e964c11105c851a52b6b60958e00442 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Sat, 12 Feb 2022 16:22:26 +0330 Subject: [PATCH 17/22] Add ssl config to nginx.conf --- docker-compose.dev.yml | 2 +- docker-compose.override.yml | 2 +- nginx.conf | 19 ++++++++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index d244d25..e8cc42d 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -2,4 +2,4 @@ version: '3.8' services: nginx: ports: - - '80:80' \ No newline at end of file + - '8443:443' \ No newline at end of file diff --git a/docker-compose.override.yml b/docker-compose.override.yml index d244d25..5084fe0 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -2,4 +2,4 @@ version: '3.8' services: nginx: ports: - - '80:80' \ No newline at end of file + - '443:443' \ No newline at end of file diff --git a/nginx.conf b/nginx.conf index 3d1ce56..a1d7a80 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,4 +1,4 @@ -worker_processes 1; +worker_processes auto; events { worker_connections 1024; @@ -8,6 +8,15 @@ http { include /etc/nginx/mime.types; sendfile on; + ssl_session_cache shared:SSL:10m; + ssl_session_timeout 10m; + keepalive_timeout 70; + + ssl_certificate private.pem; + ssl_certificate_key public.pem; + ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; + ssl_ciphers HIGH:!aNULL:!MD5; + upstream docker-wallet { server wallet:8080; } @@ -46,8 +55,8 @@ http { proxy_set_header X-Forwarded-Host $server_name; server { - listen 80; - listen [::]:80; + listen 443 ssl; + listen [::]:443 ssl; server_name demo.opex.dev; @@ -57,8 +66,8 @@ http { } server { - listen 80; - listen [::]:80; + listen 443 ssl; + listen [::]:443 ssl; server_name api.opex.dev; From 90d26f15b1f8f8475b48ff74aa811ce68be1af7c Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Sat, 12 Feb 2022 16:32:29 +0330 Subject: [PATCH 18/22] Add ssl credential to Jenkinsfile --- Dockerfile | 2 +- Jenkinsfile | 7 +++++++ dev.Jenkinsfile | 7 +++++++ nginx.conf | 4 ++-- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9c7884a..e1b65c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,2 @@ FROM jboesl/docker-nginx-headers-more -COPY nginx.conf /etc/nginx/nginx.conf \ No newline at end of file +ADD nginx.conf opex.dev.crt private.pem /etc/nginx/ \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index be1bc22..fb9d3ea 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,6 +8,13 @@ pipeline { DEFAULT_NETWORK_NAME = 'demo-opex' } steps { + withCredentials([ + file(credentialsId: 'private.pem', variable: 'PRIVATE'), + file(credentialsId: 'opex.dev.crt', variable: 'PUBLIC') + ]) { + sh 'cp -f $PRIVATE ./private.pem' + sh 'cp -f $PUBLIC ./opex.dev.crt' + } sh 'docker-compose up -d --build --remove-orphans' sh 'docker image prune -f' sh 'docker network prune -f' diff --git a/dev.Jenkinsfile b/dev.Jenkinsfile index d85d169..05af7e7 100644 --- a/dev.Jenkinsfile +++ b/dev.Jenkinsfile @@ -8,6 +8,13 @@ pipeline { DEFAULT_NETWORK_NAME = 'dev-opex' } steps { + withCredentials([ + file(credentialsId: 'private.pem', variable: 'PRIVATE'), + file(credentialsId: 'opex.dev.crt', variable: 'PUBLIC') + ]) { + sh 'cp -f $PRIVATE ./private.pem' + sh 'cp -f $PUBLIC ./opex.dev.crt' + } sh 'docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --build --remove-orphans' sh 'docker image prune -f' sh 'docker network prune -f' diff --git a/nginx.conf b/nginx.conf index a1d7a80..a3f44a9 100644 --- a/nginx.conf +++ b/nginx.conf @@ -12,8 +12,8 @@ http { ssl_session_timeout 10m; keepalive_timeout 70; - ssl_certificate private.pem; - ssl_certificate_key public.pem; + ssl_certificate opex.dev.crt; + ssl_certificate_key private.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; From a2da5f882527a868c7a6fc0eb2518257ba2a055c Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Mon, 14 Feb 2022 10:51:23 +0330 Subject: [PATCH 19/22] Add auth to demo.opex.dev virtual host --- nginx.conf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nginx.conf b/nginx.conf index a3f44a9..4e8e971 100644 --- a/nginx.conf +++ b/nginx.conf @@ -63,6 +63,10 @@ http { location / { proxy_pass http://docker-web-app; } + + location /auth { + proxy_pass http://docker-auth; + } } server { From 68fc841b459e102475da6b400f697ac88251b8c1 Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Wed, 16 Feb 2022 17:11:11 +0330 Subject: [PATCH 20/22] Rewrite web app path --- nginx.conf | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/nginx.conf b/nginx.conf index 4e8e971..f481abf 100644 --- a/nginx.conf +++ b/nginx.conf @@ -59,13 +59,19 @@ http { listen [::]:443 ssl; server_name demo.opex.dev; + server_name demo.opex.dev:8443; - location / { + location /auth { + proxy_pass http://docker-auth; + } + + location ~* \.(.*)$ { proxy_pass http://docker-web-app; } - location /auth { - proxy_pass http://docker-auth; + location / { + proxy_pass http://docker-web-app; + rewrite .* / break; } } @@ -74,6 +80,7 @@ http { listen [::]:443 ssl; server_name api.opex.dev; + server_name api.opex.dev:8443; more_set_headers 'Access-Control-Allow-Origin: *'; more_set_headers 'Access-Control-Allow-Headers: *'; From dd8ae4bc5437d67003af983d93a229dce87d50fd Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Sat, 19 Feb 2022 14:43:00 +0330 Subject: [PATCH 21/22] Add dynamic DNS resolution ability --- nginx.conf | 50 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/nginx.conf b/nginx.conf index f481abf..1004cf2 100644 --- a/nginx.conf +++ b/nginx.conf @@ -61,16 +61,22 @@ http { server_name demo.opex.dev; server_name demo.opex.dev:8443; - location /auth { - proxy_pass http://docker-auth; + location ^~ /auth { + resolver 127.0.0.11; + set $backend http://docker-auth; + proxy_pass $backend; } location ~* \.(.*)$ { - proxy_pass http://docker-web-app; + resolver 127.0.0.11; + set $backend http://docker-web-app; + proxy_pass $backend; } location / { - proxy_pass http://docker-web-app; + resolver 127.0.0.11; + set $backend http://docker-web-app; + proxy_pass $backend; rewrite .* / break; } } @@ -91,7 +97,9 @@ http { } location /auth { - proxy_pass http://docker-auth; + resolver 127.0.0.11; + set $backend http://docker-auth; + proxy_pass $backend; } location /wallet/transfer { @@ -107,22 +115,30 @@ http { } location /wallet { - proxy_pass http://docker-wallet; + resolver 127.0.0.11; + set $backend http://docker-wallet; + proxy_pass $backend; rewrite ^/wallet/(.*)$ /$1 break; } location /gateway { - proxy_pass http://docker-matching-gateway; + resolver 127.0.0.11; + set $backend http://docker-matching-gateway; + proxy_pass $backend; rewrite ^/gateway/(.*)$ /$1 break; } location /storage { - proxy_pass http://docker-storage; + resolver 127.0.0.11; + set $backend http://docker-storage; + proxy_pass $backend; rewrite ^/storage/(.*)$ /$1 break; } location /stream { - proxy_pass http://docker-websocket; + resolver 127.0.0.11; + set $backend http://docker-websocket; + proxy_pass $backend; # WS config proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; @@ -132,23 +148,31 @@ http { } location /ipg { - proxy_pass http://docker-ipg; + resolver 127.0.0.11; + set $backend http://docker-ipg; + proxy_pass $backend; rewrite ^/ipg/(.*)$ /$1 break; } location /api { - proxy_pass http://docker-api; + resolver 127.0.0.11; + set $backend http://docker-api; + proxy_pass $backend; rewrite ^/api/(.*)$ /$1 break; } location /sapi { - proxy_pass http://docker-api; + resolver 127.0.0.11; + set $backend http://docker-api; + proxy_pass $backend; rewrite ^/sapi/(.*)$ /$1 break; } location /binance { + resolver 127.0.0.11; + set $backend http://api.binance.com; proxy_set_header Host api.binance.com; - proxy_pass https://api.binance.com; + proxy_pass $backend; rewrite ^/binance/(.*)$ /$1 break; } } From d8d481e8e7b657ad9f63f302dc78aa9901dcc78b Mon Sep 17 00:00:00 2001 From: metalicn20 Date: Sat, 19 Feb 2022 16:56:21 +0330 Subject: [PATCH 22/22] Update ipg port --- nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx.conf b/nginx.conf index 1004cf2..dac8a30 100644 --- a/nginx.conf +++ b/nginx.conf @@ -46,7 +46,7 @@ http { } upstream docker-ipg { - server payment:9995; + server payment:8080; } proxy_set_header Host $host;