Skip to content

Instantly share code, notes, and snippets.

@abhi-io
Created June 20, 2024 05:50
Show Gist options
  • Save abhi-io/80dffb3db427835ebfc7ed77a897cdfa to your computer and use it in GitHub Desktop.
Save abhi-io/80dffb3db427835ebfc7ed77a897cdfa to your computer and use it in GitHub Desktop.

Revisions

  1. abhi-io created this gist Jun 20, 2024.
    51 changes: 51 additions & 0 deletions nginx conf - ip server
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    # Define an upstream block for backend services
    upstream api_backend {
    server localhost:6565;
    }

    # HTTP server block to handle requests
    server {
    listen 80;
    server_name ;

    # Frontend Docker container
    location / {
    proxy_pass http://localhost:3000;
    # Optional: Add additional proxy settings if needed
    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;
    }

    # API Docker container
    location /api/ {
    proxy_pass http://api_backend/api/ ;
    # Optional: Add additional proxy settings if needed
    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;
    }

    # Optional: If you have other static files to serve
    # location /static/ {
    # alias /path/to/your/static/files;
    # # Optional: Add more directives as needed
    # }

    # Optional: If you have other services or fallback
    # location /other/ {
    # proxy_pass http://other_service/;
    # # Optional: Add more directives as needed
    # }

    # Optional: Custom error handling
    # error_page 404 /404.html;
    # location = /404.html {
    # root /path/to/your/error/files;
    # internal;
    # }

    # Additional server settings can go here
    }