Update Swagger host to port 5005 and harden Gin trusted proxies.
Also add shared nginx config for test.webulgam.com with online-backend path. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
30bcfefc1e
commit
ba53b5b5c2
7 files changed
+98
-9
No files matched your search
@@ -146,7 +146,7 @@ Authorization: <accessToken>
|
|||||||
|
|
||||||
### Swagger
|
### Swagger
|
||||||
|
|
||||||
Interactive API docs: [http://localhost:5050/swagger/index.html](http://localhost:5050/swagger/index.html)
|
Interactive API docs: [http://localhost:5005/swagger/index.html](http://localhost:5005/swagger/index.html)
|
||||||
|
|
||||||
## Database migrations
|
## Database migrations
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
// @title Service APIs
|
// @title Service APIs
|
||||||
// @version 1.0
|
// @version 1.0
|
||||||
// @description Online payment system admin API.
|
// @description Online payment system admin API.
|
||||||
// @host localhost:5050
|
// @host localhost:5005
|
||||||
// @BasePath /api/admin
|
// @BasePath /api/admin
|
||||||
// @securityDefinitions.apikey BearerAuth
|
// @securityDefinitions.apikey BearerAuth
|
||||||
// @in header
|
// @in header
|
||||||
@@ -44,16 +44,16 @@ import (
|
|||||||
// @tag.name activity-logs
|
// @tag.name activity-logs
|
||||||
// @tag.description User activity audit trail
|
// @tag.description User activity audit trail
|
||||||
func main() {
|
func main() {
|
||||||
|
cfg := config.GetConfig()
|
||||||
|
logger := logging.GetLogger()
|
||||||
|
|
||||||
docs.SwaggerInfo.Title = "Service APIs"
|
docs.SwaggerInfo.Title = "Service APIs"
|
||||||
docs.SwaggerInfo.Version = "1.0"
|
docs.SwaggerInfo.Version = "1.0"
|
||||||
docs.SwaggerInfo.Description = "Online payment system admin API."
|
docs.SwaggerInfo.Description = "Online payment system admin API."
|
||||||
docs.SwaggerInfo.Host = "localhost:5050"
|
docs.SwaggerInfo.Host = "localhost:" + cfg.Listen.Port
|
||||||
docs.SwaggerInfo.BasePath = "/api/admin"
|
docs.SwaggerInfo.BasePath = "/api/admin"
|
||||||
docs.SwaggerInfo.Schemes = []string{"http"}
|
docs.SwaggerInfo.Schemes = []string{"http"}
|
||||||
|
|
||||||
cfg := config.GetConfig()
|
|
||||||
logger := logging.GetLogger()
|
|
||||||
|
|
||||||
pool := mustConnectPostgresql(cfg, logger)
|
pool := mustConnectPostgresql(cfg, logger)
|
||||||
router := handlermanager.New(cfg, pool, logger)
|
router := handlermanager.New(cfg, pool, logger)
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -7094,7 +7094,7 @@ const docTemplate = `{
|
|||||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||||
var SwaggerInfo = &swag.Spec{
|
var SwaggerInfo = &swag.Spec{
|
||||||
Version: "1.0",
|
Version: "1.0",
|
||||||
Host: "localhost:5050",
|
Host: "localhost:5005",
|
||||||
BasePath: "/api/admin",
|
BasePath: "/api/admin",
|
||||||
Schemes: []string{},
|
Schemes: []string{},
|
||||||
Title: "Service APIs",
|
Title: "Service APIs",
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
"contact": {},
|
"contact": {},
|
||||||
"version": "1.0"
|
"version": "1.0"
|
||||||
},
|
},
|
||||||
"host": "localhost:5050",
|
"host": "localhost:5005",
|
||||||
"basePath": "/api/admin",
|
"basePath": "/api/admin",
|
||||||
"paths": {
|
"paths": {
|
||||||
"/activity-logs": {
|
"/activity-logs": {
|
||||||
|
|||||||
+1
-1
@@ -1214,7 +1214,7 @@ definitions:
|
|||||||
- branchId
|
- branchId
|
||||||
- userId
|
- userId
|
||||||
type: object
|
type: object
|
||||||
host: localhost:5050
|
host: localhost:5005
|
||||||
info:
|
info:
|
||||||
contact: {}
|
contact: {}
|
||||||
description: Online payment system admin API.
|
description: Online payment system admin API.
|
||||||
|
|||||||
@@ -25,6 +25,14 @@ func New(cfg *config.Config, client *pgxpool.Pool, logger *logging.Logger) *gin.
|
|||||||
}
|
}
|
||||||
|
|
||||||
router := gin.New()
|
router := gin.New()
|
||||||
|
// Trust only loopback and private networks (Docker/K8s/nginx), not all proxies.
|
||||||
|
_ = router.SetTrustedProxies([]string{
|
||||||
|
"127.0.0.1",
|
||||||
|
"::1",
|
||||||
|
"10.0.0.0/8",
|
||||||
|
"172.16.0.0/12",
|
||||||
|
"192.168.0.0/16",
|
||||||
|
})
|
||||||
router.Use(gin.Recovery(), gin.Logger())
|
router.Use(gin.Recovery(), gin.Logger())
|
||||||
router.Use(cors.New(cors.Config{
|
router.Use(cors.New(cors.Config{
|
||||||
AllowOrigins: []string{"*"},
|
AllowOrigins: []string{"*"},
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
# /etc/nginx/sites-available/test.webulgam.com.conf
|
||||||
|
# ln -s /etc/nginx/sites-available/test.webulgam.com.conf /etc/nginx/sites-enabled/
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name test.webulgam.com;
|
||||||
|
|
||||||
|
if ($host = test.webulgam.com) {
|
||||||
|
return 301 https://$host$request_uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 404;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
server_name test.webulgam.com;
|
||||||
|
|
||||||
|
root /var/www/tbbank.gov.tm/frontend/src;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
charset utf-8;
|
||||||
|
client_max_body_size 100M;
|
||||||
|
|
||||||
|
add_header X-Frame-Options "SAMEORIGIN";
|
||||||
|
add_header X-Content-Type-Options "nosniff";
|
||||||
|
|
||||||
|
ssl_certificate /etc/letsencrypt/live/test.webulgam.com/fullchain.pem;
|
||||||
|
ssl_certificate_key /etc/letsencrypt/live/test.webulgam.com/privkey.pem;
|
||||||
|
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||||
|
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
||||||
|
|
||||||
|
# --- existing project → :5050 ---
|
||||||
|
location /admin {
|
||||||
|
proxy_pass http://127.0.0.1:5050;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /public/ {
|
||||||
|
proxy_pass http://127.0.0.1:5050;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /api {
|
||||||
|
proxy_pass http://127.0.0.1:5050;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- online-backend → :5005 ---
|
||||||
|
# Example: https://test.webulgam.com/online-backend/api/admin/...
|
||||||
|
location /online-backend/ {
|
||||||
|
rewrite ^/online-backend/(.*)$ /$1 break;
|
||||||
|
proxy_pass http://127.0.0.1:5005;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
location = /favicon.ico { access_log off; log_not_found off; }
|
||||||
|
location = /robots.txt { access_log off; log_not_found off; }
|
||||||
|
|
||||||
|
error_page 404 /index.php;
|
||||||
|
|
||||||
|
location ~ /\.(?!well-known).* {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user