[{"data":1,"prerenderedAt":129},["ShallowReactive",2],{"seo-verification":3,"blog-deploying-a-go-gin-application-on-a-vps-en":6},{"google":4,"bing":5},"EycwPY2XMyTkVzas3n1ygeNJFGAH513qrMjfDljzsMQ","",{"id":7,"slug":8,"slugs":9,"title":12,"excerpt":13,"readTime":14,"views":15,"isPinned":16,"publishedAt":17,"category":18,"categories":24,"featuredImage":26,"bgImage":27,"posterImage":28,"relatedSolution":29,"intro":32,"sections":33,"ctaTitle":79,"ctaBody":80,"ctaButton":81,"ctaUrl":82,"relatedPosts":83},51,"deploying-a-go-gin-application-on-a-vps",{"fr":10,"en":8,"ar":11},"deployer-golang-vps","نشر-تطبيق-go-gin-على-خادم-vps","Deploying a Go (Gin) application on a VPS","Deploy a Go (Gin) API on a Cloud VPS: static binary, Docker scratch, reverse proxy and SSL. A tutorial for Go developers.",3,0,false,"2026-04-30T00:00:00+00:00",{"id":19,"name":20,"slug":21,"color":22,"icon":23},4,"Development","developpement","bg-warning\u002F10 text-warning","dev",[25],{"id":19,"name":20,"slug":21,"color":22,"icon":23},null,"\u002Fblog\u002Fcovers\u002Fbg.svg","\u002Fblog\u002Fcovers\u002Fdeployer-golang-vps-poster.svg",{"categorySlug":30,"appSlug":31},"development","golang","Go compiles into a single static binary with no dependencies: it's the ideal language for self-hosting. A Gin API fits in a few megabytes of RAM and starts instantly. Here is how to put it into production on a VPS, from the binary to the SSL certificate.",[34,38,48,51,73,76],{"type":35,"title":36,"body":37},"h2","Why self-host a Go API on a VPS","Unlike Java or Node, a Go application (with the Gin framework) compiles into a single static binary that needs neither an interpreter, nor a runtime, nor a shared library. You can literally drop the binary onto a VPS and run it. This lightness changes everything for self-hosting: a Gin API runs in 15 to 30 MB of RAM and starts in a few milliseconds; the throughput it sustains depends on what your handler does, and is measured against your own workload. On a VPS, you make the most of this efficiency: an entry-level server is enough to serve a load that interpreted languages would require a much bigger machine for. You also avoid the complexity of bulky Docker images: a 10 MB `scratch` image is enough.",{"type":39,"title":40,"items":41},"ul","Concrete benefits",[42,43,44,45,46,47],"Single static binary: no runtime to install, deployment by a simple file copy","Tiny memory footprint (15-30 MB) allowing you to saturate a small VPS with requests","`scratch` or `distroless` Docker image of 10-15 MB: near-instant builds and pulls","Startup in milliseconds: redeployments and restarts with no perceptible interruption","Native concurrency via goroutines: a single vCPU handles thousands of simultaneous connections","Reduced attack surface: no interpreter or system packages to patch",{"type":35,"title":49,"body":50},"Hardware and software prerequisites","This is where Go shines: a Gin API without a database fits on a VPS with 1 vCPU and 1 GB of RAM, and stays at ease. With co-located PostgreSQL, aim for 2 GB to be comfortable. You don't even need Go on the server if you compile in CI or by local cross-compilation (`GOOS=linux GOARCH=amd64 go build`). Install Docker if you containerize, or nothing at all if you launch the binary directly under systemd. Point an `api.mydomain.com` domain at the VPS IP via an A record. 5 GB of disk is more than enough.",{"type":52,"title":53,"steps":54},"steps","Step-by-step deployment",[55,58,61,64,67,70],{"title":56,"body":57},"Cross-compile the binary for Linux","From your workstation, run `CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app .`. The `CGO_ENABLED=0` flag guarantees a 100% static binary, indispensable for a `scratch` image. You get an `app` executable ready to run on any Linux.",{"title":59,"body":60},"Build a minimal Docker image","Write a multi-stage Dockerfile: a `golang:1.22-alpine` stage to compile, then `FROM scratch` which copies only the binary and the CA certificates (`COPY --from=builder \u002Fetc\u002Fssl\u002Fcerts ...`). The final image weighs about ten MB. Expose port 8080.",{"title":62,"body":63},"Configure Gin for production","Switch Gin to release mode with `gin.SetMode(gin.ReleaseMode)` or the `GIN_MODE=release` variable to disable the verbose debug logs. Read the port and the secrets from the environment (`os.Getenv`), never hard-coded in the code.",{"title":65,"body":66},"Launch the container","Start with `docker run -d --restart unless-stopped -p 127.0.0.1:8080:8080 -e GIN_MODE=release monapp:latest`. By binding on `127.0.0.1`, you expose Gin only to the local reverse proxy, not directly to the Internet.",{"title":68,"body":69},"Place Nginx or Caddy in front","Configure a reverse proxy to `http:\u002F\u002F127.0.0.1:8080`. Caddy is particularly well suited here: with a simple `reverse_proxy localhost:8080` directive, it automatically provisions the HTTPS certificate without Certbot.",{"title":71,"body":72},"Secure with TLS","With Caddy, HTTPS is automatic as soon as the domain points to the VPS. With Nginx, run `certbot --nginx -d api.mydomain.com`. Then check the TLS chain with `curl -I https:\u002F\u002Fapi.mydomain.com`.",{"type":74,"body":75},"tip","Enable Go's `pprof` profiling behind a protected endpoint: `import _ \"net\u002Fhttp\u002Fpprof\"` exposed on an internal port only accessible via an SSH tunnel. You get CPU and memory flame graphs in real production without noticeable overhead. Also consider compiling with `-ldflags=\"-s -w\"` to reduce the binary size by 30% by removing the debug tables.",{"type":35,"title":77,"body":78},"Deploy Go (Gin) in One Click from the ServOrbit Marketplace","The ServOrbit Marketplace offers a preconfigured Go (Gin) Stack template: Go 1.22+ from the official go.dev binary, Nginx, and PostgreSQL 16 are installed automatically on your VPS from the order form. No SSH session for the base setup — you arrive directly at the step of compiling your project and uploading the binary. The marketplace page contains the exact specifications, use cases, and a first-connection guide.","Deploy your Go (Gin) Stack in minutes","The ServOrbit Go (Gin) Stack template installs Go 1.22+, Nginx, and PostgreSQL 16 on your VPS. Cross-compile your project and deploy the binary immediately.","Deploy Go (Gin) Stack","\u002Fmarketplace\u002Fdevelopment\u002Fgolang",[84,99,114],{"id":85,"slug":86,"slugs":87,"title":90,"excerpt":91,"readTime":14,"views":15,"isPinned":16,"publishedAt":92,"category":93,"categories":94,"featuredImage":26,"bgImage":27,"posterImage":96,"relatedSolution":97},45,"deploy-a-fastapi-application-on-a-vps",{"fr":88,"en":86,"ar":89},"deployer-fastapi-vps","نشر-تطبيق-fastapi-على-vps","Deploy a FastAPI Application on a VPS","Deploy FastAPI on a VPS with Uvicorn, Gunicorn, Nginx, and SSL. A guide for Python developers who want a self-hosted async API.","2026-05-06T00:00:00+00:00",{"id":19,"name":20,"slug":21,"color":22,"icon":23},[95],{"id":19,"name":20,"slug":21,"color":22,"icon":23},"\u002Fblog\u002Fcovers\u002Fdeployer-fastapi-vps-poster.svg",{"categorySlug":30,"appSlug":98},"fastapi",{"id":100,"slug":101,"slugs":102,"title":105,"excerpt":106,"readTime":14,"views":15,"isPinned":16,"publishedAt":107,"category":108,"categories":109,"featuredImage":26,"bgImage":27,"posterImage":111,"relatedSolution":112},44,"deploy-a-django-application-on-a-vps",{"fr":103,"en":101,"ar":104},"deployer-django-vps","نشر-تطبيق-django-على-vps","Deploy a Django Application on a VPS","Deploy Django on a VPS: Gunicorn, Nginx, PostgreSQL, Docker, and SSL. A complete guide for Python developers who want to self-host.","2026-05-07T00:00:00+00:00",{"id":19,"name":20,"slug":21,"color":22,"icon":23},[110],{"id":19,"name":20,"slug":21,"color":22,"icon":23},"\u002Fblog\u002Fcovers\u002Fdeployer-django-vps-poster.svg",{"categorySlug":30,"appSlug":113},"django",{"id":115,"slug":116,"slugs":117,"title":120,"excerpt":121,"readTime":14,"views":15,"isPinned":16,"publishedAt":122,"category":123,"categories":124,"featuredImage":26,"bgImage":27,"posterImage":126,"relatedSolution":127},43,"deploy-a-nodejs-application-on-a-vps",{"fr":118,"en":116,"ar":119},"deployer-nodejs-vps","نشر-تطبيق-nodejs-على-vps","Deploy a Node.js Application on a VPS","Deploy a Node.js application to production on a VPS: PM2, Nginx reverse proxy, Let's Encrypt SSL, and automatic startup at boot.","2026-05-08T00:00:00+00:00",{"id":19,"name":20,"slug":21,"color":22,"icon":23},[125],{"id":19,"name":20,"slug":21,"color":22,"icon":23},"\u002Fblog\u002Fcovers\u002Fdeployer-nodejs-vps-poster.svg",{"categorySlug":30,"appSlug":128},"nodejs-stack",1787580996415]