Giter Club home page Giter Club logo

nginx-render's Introduction

Nginx to be used as a Docker deployment on Render.

Why does this exist?

Render is great in that you can build and run any dockerized service. However, in order to do so, you must provide the Dockerfile within a repository for it to build, so publicly available images can't be used directly. That said, this repository simply wraps nginx in another Dockerfile that render will build and run.

nginx makes a good reverse proxy so that you can create all of your services as "Private Services" on Render except for this nginx service. This helps provide a level of security and also allows you to route traffic by path on the same hostname.

How to use

  1. Reference the repository URL as a public repository when launching a new service.
  2. Create a secret file named nginx.conf. This will be the configuration file nginx will use.

Sample nginx.conf

Below is an example of a configuration file with a health check and a path for which nginx serves as a reverse proxy.

upstream my_service {
  server myservice:1000;
}

server {
  listen 1000;
  listen [::]:1000;

  server_name foobar.onrender.com;

  location /healthz {
    return 200 'ok';
    add_header Content-Type text/plain;
  }

  location /some/path {
    proxy_pass http://my_service/;
    proxy_cache_bypass $http_upgrade;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    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;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Port $server_port;
  }
} 

In this example, foobar.onrender.com is the hostname of the service on Render, listening on port 1000. You'll need to change both the hostname and port to match the service.

foobar.onrender.com/healthz is a health check URL that does nothing by return a 200 status code.

foobar.onrender.com/some/path is reverse proxied to the upstream service titled "my_service". This service is defined by the host:port combination myservice:1000. Change this to match the private service you want to reverse proxy on Render.

Contributing

  • Please file an issue if there's a bug or feature request.
  • Pull requests are welcome and will be reviewed/merged as appropriate.

License

MIT License

nginx-render's People

Contributors

knation avatar qqkr2023 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.