From cf4331ef1e7890db93c5c228599681df60c4e42e Mon Sep 17 00:00:00 2001 From: lkzc19 Date: Tue, 16 Jul 2024 01:40:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E6=95=B4=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v-demo/shortlink/shortlink-spring/Dockerfile | 2 +- .../example/controller/ShortlinkController.kt | 6 ++- .../src/main/resources/application-dev.yml | 5 ++ .../src/main/resources/application-prod.yml | 5 ++ .../src/main/resources/application.properties | 3 -- .../src/main/resources/application.yml | 8 ++++ v-ops/ops-nginx/archives/nl.conf | 48 +++++++++++++++++++ v-ops/ops-nginx/archives/ssl.conf | 33 +++++++++++++ 8 files changed, 104 insertions(+), 6 deletions(-) create mode 100644 v-demo/shortlink/shortlink-spring/src/main/resources/application-dev.yml create mode 100644 v-demo/shortlink/shortlink-spring/src/main/resources/application-prod.yml delete mode 100644 v-demo/shortlink/shortlink-spring/src/main/resources/application.properties create mode 100644 v-demo/shortlink/shortlink-spring/src/main/resources/application.yml create mode 100644 v-ops/ops-nginx/archives/nl.conf create mode 100644 v-ops/ops-nginx/archives/ssl.conf diff --git a/v-demo/shortlink/shortlink-spring/Dockerfile b/v-demo/shortlink/shortlink-spring/Dockerfile index fbda7bf..e124731 100644 --- a/v-demo/shortlink/shortlink-spring/Dockerfile +++ b/v-demo/shortlink/shortlink-spring/Dockerfile @@ -6,4 +6,4 @@ COPY ./build/libs/shortlink-0.0.1-SNAPSHOT.jar app.jar EXPOSE 3000 -ENTRYPOINT ["java", "-jar", "app.jar"] +ENTRYPOINT ["java", "-Dspring.profiles.active=prod", "-jar", "app.jar"] diff --git a/v-demo/shortlink/shortlink-spring/src/main/kotlin/org/example/controller/ShortlinkController.kt b/v-demo/shortlink/shortlink-spring/src/main/kotlin/org/example/controller/ShortlinkController.kt index 7195c47..3ce4d8a 100644 --- a/v-demo/shortlink/shortlink-spring/src/main/kotlin/org/example/controller/ShortlinkController.kt +++ b/v-demo/shortlink/shortlink-spring/src/main/kotlin/org/example/controller/ShortlinkController.kt @@ -6,6 +6,7 @@ import com.google.zxing.client.j2se.MatrixToImageWriter import com.google.zxing.qrcode.QRCodeWriter import org.example.LinkMap import org.example.base62Map +import org.springframework.beans.factory.annotation.Value import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity import org.springframework.web.bind.annotation.GetMapping @@ -21,7 +22,8 @@ import kotlin.io.encoding.ExperimentalEncodingApi class ShortlinkController { val hashUtils = MurmurHash3() - val prefix = "http://localhost:3000/" + @Value("\${vitamin.prefix}") + lateinit var prefix: String @OptIn(ExperimentalEncodingApi::class) @GetMapping("/") @@ -74,6 +76,6 @@ class ShortlinkController { @GetMapping("/ping") fun ping(): String { - return "pong..." + return "pong...$prefix" } } \ No newline at end of file diff --git a/v-demo/shortlink/shortlink-spring/src/main/resources/application-dev.yml b/v-demo/shortlink/shortlink-spring/src/main/resources/application-dev.yml new file mode 100644 index 0000000..5a57af2 --- /dev/null +++ b/v-demo/shortlink/shortlink-spring/src/main/resources/application-dev.yml @@ -0,0 +1,5 @@ +server: + port: 3000 + +vitamin: + prefix: http://localhost:3000/ \ No newline at end of file diff --git a/v-demo/shortlink/shortlink-spring/src/main/resources/application-prod.yml b/v-demo/shortlink/shortlink-spring/src/main/resources/application-prod.yml new file mode 100644 index 0000000..0eeb127 --- /dev/null +++ b/v-demo/shortlink/shortlink-spring/src/main/resources/application-prod.yml @@ -0,0 +1,5 @@ +server: + port: 3000 + +vitamin: + prefix: https://drinkice.xyz/ \ No newline at end of file diff --git a/v-demo/shortlink/shortlink-spring/src/main/resources/application.properties b/v-demo/shortlink/shortlink-spring/src/main/resources/application.properties deleted file mode 100644 index 259e519..0000000 --- a/v-demo/shortlink/shortlink-spring/src/main/resources/application.properties +++ /dev/null @@ -1,3 +0,0 @@ -spring.application.name=shortlink - -server.port=3000 diff --git a/v-demo/shortlink/shortlink-spring/src/main/resources/application.yml b/v-demo/shortlink/shortlink-spring/src/main/resources/application.yml new file mode 100644 index 0000000..19e3fb8 --- /dev/null +++ b/v-demo/shortlink/shortlink-spring/src/main/resources/application.yml @@ -0,0 +1,8 @@ +spring: + application: + name: shortlink + profiles: + active: dev + +vitamin: + perfix: http://localhost:3000/ \ No newline at end of file diff --git a/v-ops/ops-nginx/archives/nl.conf b/v-ops/ops-nginx/archives/nl.conf new file mode 100644 index 0000000..48653b2 --- /dev/null +++ b/v-ops/ops-nginx/archives/nl.conf @@ -0,0 +1,48 @@ +charset utf-8; # 避免中文乱码 + +autoindex on; #开启索引功能 +autoindex_exact_size off; #关闭计算文件确切大小(单位bytes),只显示大概大小(单位kb、mb、gb) +autoindex_localtime on; #显示本机时间而非 GMT 时间 + + +server { + listen 80; + server_name nahidalibrary.xyz; + + location /nlib/ { + alias /nahida-library/nlib/; + } + + location /api/ { + proxy_pass http://0.0.0.0:9100/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } +} + +upstream nacos-cluster { + server nacos01:9848; +} + +server { + listen 9848; + server_name nacos01; + + location /nacos { + proxy_pass http://nacos-cluster/nacos; + } +} + +server { + listen 9900; + server_name webhook; + + location ~ ^/webhook/(.*)$ { + proxy_pass http://0.0.0.0:9000/hooks/$1; + } +} \ No newline at end of file diff --git a/v-ops/ops-nginx/archives/ssl.conf b/v-ops/ops-nginx/archives/ssl.conf new file mode 100644 index 0000000..958f457 --- /dev/null +++ b/v-ops/ops-nginx/archives/ssl.conf @@ -0,0 +1,33 @@ +server { + listen 443 ssl; + server_name drinkice.xyz; + + # 设置ssl证书文件路径 + ssl_certificate certs/drinkice.xyz.pem; + ssl_certificate_key certs/drinkice.xyz.key; + + ssl_session_timeout 5m; + ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; + ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; + ssl_prefer_server_ciphers on; + add_header Strict-Transport-Security "max-age=31536000"; + + # 访问日志 + access_log /var/log/nginx/drinkice.xyz.https.log; + + + location /file/ { + alias /nahida-library/nlib/; + } + + location / { + proxy_pass http://0.0.0.0:9876/; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root html; + } +} \ No newline at end of file