{"id":13825825,"url":"https://github.com/franciscoknebel/nginx-reverseproxy","last_synced_at":"2025-10-31T11:30:35.798Z","repository":{"id":98889795,"uuid":"63012775","full_name":"FranciscoKnebel/nginx-reverseproxy","owner":"FranciscoKnebel","description":"A simple implementation of a multidomain nginx reverse proxy, using Node apps.","archived":false,"fork":false,"pushed_at":"2018-08-28T13:44:45.000Z","size":296,"stargazers_count":47,"open_issues_count":0,"forks_count":11,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-20T04:33:01.660Z","etag":null,"topics":["nginx","nginx-proxy","nginx-reverseproxy","proxy","proxy-server"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FranciscoKnebel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-07-10T18:28:15.000Z","updated_at":"2024-02-19T22:22:54.000Z","dependencies_parsed_at":"2023-03-05T17:30:43.197Z","dependency_job_id":null,"html_url":"https://github.com/FranciscoKnebel/nginx-reverseproxy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FranciscoKnebel%2Fnginx-reverseproxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FranciscoKnebel%2Fnginx-reverseproxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FranciscoKnebel%2Fnginx-reverseproxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FranciscoKnebel%2Fnginx-reverseproxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FranciscoKnebel","download_url":"https://codeload.github.com/FranciscoKnebel/nginx-reverseproxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239188479,"owners_count":19597028,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nginx","nginx-proxy","nginx-reverseproxy","proxy","proxy-server"],"created_at":"2024-08-04T09:01:27.657Z","updated_at":"2025-10-31T11:30:35.742Z","avatar_url":"https://github.com/FranciscoKnebel.png","language":"JavaScript","funding_links":[],"categories":["\u003ca id=\"01e6651181d405ecdcd92a452989e7e0\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"e9f97504fbd14c8bb4154bd0680e9e62\"\u003e\u003c/a\u003e反向代理"],"readme":"# nginx-reverseproxy\n\nA simple reverse proxy for hosting multiple apps on the same server.\nThe proxy listens on port 80 (or 443, if using the HTTP2 implementation) and, depending on the domain provided,\nredirects the user to a specific port, where one Node app is listening.\n\nThis implementation mantains applications independent between themselves, making it so one's bad behaviour won't influence the other.\nApps can also be paused, restarted or updated in an independent form. Changes to the proxy server won't affect the application behavior, as it will still stay online even if the server is not reachable.\n\n\n### Usage\n1. Install `nginx` on your server (examples using apt):\n```\n  sudo apt-get install nginx\n```\n\n2. Edit the `default` server block configuration file:\n```\n  sudo nano /etc/nginx/sites-available/default\n```\n\n3. Delete everything on the file, and include your new proxy server:\n  - If you want the regular HTTP, copy the file `nginx/default`.\n  - Otherwise, if you want the HTTP2 version _(recommended)_, use the file `nginx/default-http2`. Please view the tutorial to setup HTTPS in the `Setting up HTTPS` section, as it is needed to run HTTP2.\n\n  This example creates proxies for three apps, each running on a different domain (check the value of `server_name` in each server block), and each running on a different proxy_pass port, where your app will be running.\n\n  **Make sure each app runs on the same port as the one you choose on the proxy_pass.**\n\n4. Once you are sure your apps are running on the correct ports, restart the `nginx` service and it should be working as expected:\n\n```\nsudo service nginx restart\n```\n\n### Setting up HTTPS\n\n1. Generate your `dhparam.pem` file, running in the terminal\n```\nopenssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048\n```\n#### Create a SSL certificate using Let's Encrypt\n~~How to create a certificate, complete guide.~~\n\n~~https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04~~\n\nUsing [Certbot](https://certbot.eff.org/) is easier and simpler to configure https://certbot.eff.org/lets-encrypt/ubuntuartful-nginx.\n\n1. Pause Nginx:\n```\nsudo service nginx stop\n```\n\n2. Install Certbot\n```\nsudo apt-get update\nsudo apt-get install software-properties-common\nsudo add-apt-repository ppa:certbot/certbot\nsudo apt-get update\nsudo apt-get install python-certbot-nginx \n```\n\n3. Create certificate for each site (regular domain and with www):\n```\nsudo certbot --nginx\n```\n\n4. Follow the steps on the screen. Certbot is a smart bot :)\n\n5. Restart Nginx and everything should be working:\n```\nsudo service nginx restart\n```\n\n6.1 To renew the certificates manually\n```\nsudo certbot renew --dry-run\n```\n6.2 To renew automatically\n```\nsudo crontab -e\n\nInsert the next two lines.\n\n30 2 * * 1 /usr/bin/certbot renew --dry-run\n35 2 * * 1 /bin/systemctl reload nginx\n```\n\nTo test your nginx configuration, you can use the following:\n```\nsudo nginx -t\n```\nThis wil check your configuration for correct syntax and then try to open files referred in configuration.\n\n---\n###### Extra\n* To make it so the user can't access your app ports directly (example1.com:8001), you need to add a `hostname` to your `app.listen` instruction. That way, the proxy will be the only one who can access those ports, so it can redirect to the user.\n\n```\nvar listener = app.listen(port, 'localhost', function() {\n    console.log(\"Listening on port \" + listener.address().port);\n});\n```\n\n* https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04\n\n###### Original question can be found at [DigitalOcean](https://www.digitalocean.com/community/questions/two-different-node-apps-with-two-different-domains-in-one-droplet).\n---\n\n#### License\nMIT License. [Click here for more information.](LICENSE)\n\n---\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranciscoknebel%2Fnginx-reverseproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffranciscoknebel%2Fnginx-reverseproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffranciscoknebel%2Fnginx-reverseproxy/lists"}