{"id":14986197,"url":"https://github.com/codeyellowbv/vagrant-reverse-proxy","last_synced_at":"2025-07-20T17:04:39.340Z","repository":{"id":56897245,"uuid":"53678402","full_name":"CodeYellowBV/vagrant-reverse-proxy","owner":"CodeYellowBV","description":"Automatic reverse VM proxy plugin for Vagrant","archived":false,"fork":false,"pushed_at":"2017-09-08T08:09:09.000Z","size":29,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-07-13T00:14:58.852Z","etag":null,"topics":["nginx-configuration","proxy","reverse-proxy","vagrant","virtual-machine"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","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/CodeYellowBV.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-11T15:55:58.000Z","updated_at":"2017-11-18T06:50:07.000Z","dependencies_parsed_at":"2022-08-20T17:40:33.312Z","dependency_job_id":null,"html_url":"https://github.com/CodeYellowBV/vagrant-reverse-proxy","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/CodeYellowBV/vagrant-reverse-proxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeYellowBV%2Fvagrant-reverse-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeYellowBV%2Fvagrant-reverse-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeYellowBV%2Fvagrant-reverse-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeYellowBV%2Fvagrant-reverse-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodeYellowBV","download_url":"https://codeload.github.com/CodeYellowBV/vagrant-reverse-proxy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodeYellowBV%2Fvagrant-reverse-proxy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266161906,"owners_count":23885928,"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-configuration","proxy","reverse-proxy","vagrant","virtual-machine"],"created_at":"2024-09-24T14:12:30.831Z","updated_at":"2025-07-20T17:04:39.311Z","avatar_url":"https://github.com/CodeYellowBV.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vagrant Reverse Proxy\n\nThis Vagrant plugin automatically installs a reverse proxy\nconfiguration for each of your Vagrant machines.\n\nThis means you can access the HTTP interface of your virtual machines\nby accessing HTTP on your machine's IP address or DNS hostname, with\na suffix that indicates the VM.\n\nIn other words, `http://localhost/my-vm` refers to `http://my-vm/` on\nthe local machine.  This also works if you access it from an external\nmachine, even though `my-vm` is a local machine name unknown on the\nnetwork.\n\nThis plugin currently only supports NGINX, but patches are accepted to\nintegrate it with other web servers.\n\n## Installation\n\nInstall the plugin as usual:\n\n    $ vagrant plugin install vagrant-reverse-proxy\n\n## Usage\n\nFirst, install NGINX and create a configuration as usual.  Then, in\nthe `server` configuration block for the host you want to use for\nproxying, simply put `include \"vagrant-proxy-config-locations\";` in the file.\n\nIf you don't need anything specific, just put the following in\n`/etc/nginx/sites-enabled/default`:\n\n    server {\n        listen 80 default;\n        listen [::]:80 default;\n        # This is the fallback server\n        server_name default;\n        # Redirect http://localhost/hostname/lalala\n        # to http://hostname/lalala\n        include \"vagrant-proxy-config-locations\";\n    }\n\nThis will load the `/etc/nginx/vagrant-proxy-config` file which is\nmanaged by this plugin.  This file contains `location` statements for\neach of your virtual machines, such that `http://localhost/foo` will\nproxy to port 80 on the virtual machine with a `config.vm.hostname`\nvalue of `foo`.  This is only done for virtual machines that have\n`config.reverse_proxy.enabled` set to `true` in their config.\n\n#### Server Blocks\n\nThe plugin also writes `server` block configuration for the enabled\nVMs so that they can be accessed directly via their hostname (as long\nas the hostname resolves to the host machine's IP address).\n\nTo include these, simply include the generated file inside your main NGINX `http` block:\n\n    http {\n        include \"vagrant-proxy-config-servers\";\n    }\n\n\nWhenever you bring up, halt, or reload a machine, the plugin updates the proxy\nconfig files and invokes `sudo nginx -s reload` to make the change immediately visible.\n\n### Custom host names\n\nSometimes you want to support several virtual hosts for one VM.  To\nset that up, you can override the `vhosts` option:\n\n    config.reverse_proxy.vhosts = ['foo.test', 'bar.test']\n\nThis will proxy `http://localhost/foo.test` and\n`http://localhost/bar.test` to this VM, with a matching `Host` header.\n\nIf you want to customize the vhost path, you can use a hash instead of\nan array:\n\n    config.reverse_proxy.vhosts = {\n        \"foo-test\" =\u003e \"foo.test\",\n        \"bar\" =\u003e \"bar.test\"\n        \"bar-altport\" =\u003e {:host =\u003e \"bar.test\", :port =\u003e 8080}\n    }\n\nAs you can see, this allows you to define which port to connect to\ninstead of the default port (which is port 80).\n\n### Specifying the NGINX configuration file paths\n\nIf you want to change the location of the managed NGINX configuration\nfiles, set the `config.reverse_proxy.nginx_locations_config_file` or\n`config.reverse_proxy.nginx_servers_config_file` values to paths on\nyour host machine in the Vagrantfile configuration:\n\n    config.reverse_proxy.nginx_locations_config_file = '/usr/local/etc/nginx/vagrant-proxy-config-locations'\n    config.reverse_proxy.nginx_servers_config_file = '/usr/local/etc/nginx/vagrant-proxy-config-servers'\n\nIf you don't want to generate one of the locations or server configuration files, set the appropriate config value to `nil`.\n\n### Specifying the NGINX reload command\n\nAfter the NGINX configuration file is generated, a reload command is\nexecuted so that the changes take effect. By default the command\nexecuted is `sudo nginx -s reload`. If you need to change this, set\nthe `config.reverse_proxy.nginx_reload_command` option to the command\nto be executed:\n\n    config.reverse_proxy.nginx_reload_command = 'sudo service nginx reload'\n\n### Adding custom NGINX configuration to your proxy\n\nSometimes the standard settings are not enough, and you'll need\nadditional custom configuration in a proxy block.  A good example is\nwhen you want to support websockets; in order to do that, you need to\nforce NGINX to use HTTP/1.1 and pass on any `upgrade` headers to the\ndownstream server.\n\nTo do this, you can add a global setting that will affect all vhosts:\n\n    config.reverse_proxy.nginx_extra_config = \u003c\u003cEOF\n        proxy_http_version 1.1;\n        proxy_set_header Upgrade $http_upgrade;\n        proxy_set_header Connection \"upgrade\";\n    EOF\n\nIf you have a particular setting that applies to a single vhost only,\nyou can set a similar property in the vhost hash:\n\n    config.reverse_proxy.vhosts = {\n        \"bar\" =\u003e {:host =\u003e \"bar.test\",\n                  :nginx_extra_config =\u003e \"proxy_http_version 1.1;\\nproxy_set_header Upgrade $http_upgrade;\\n\"}\n    }\n\nThese \"extra configs\" will be appended to the configuration, with the\nvhost-specific one last.  Of course, for more complicated\nconfiguration you can just use the NGINX `include` directive to load\nan extra file.  **NOTE:** Remember that all NGINX config directives\nrequire a trailing semicolon, or the config will be invalid!\n\n## Adding proxy support to your application\n\nThis plugin will instruct NGINX to pass the following headers to your\nVagrant box:\n\n- `X-Forwarded-For`: This contains the IP address of the client.\n- `X-Forwarded-Host`: This contains the IP address of your hypervisor.\n- `X-Forwarded-Port`: This contains the port number of NGINX on your hypervisor.\n- `X-Base-Url`: This contains the base URL that redirects to this VM.\n\nRedirects are transparently rewritten by NGINX, but if your\napplication generates links with absolute URLs, you'll need to ensure\nthat those links are prefixed with the value of `X-Base-Url`, but only\nif the request originated from the trusted NGINX proxy on your\nhypervisor.\n\nBe sure to avoid using these headers when the request originated\nelsewhere, because trusting these headers as sent by arbitrary clients\nis a potential security issue!  If you're using Laravel, you could\nconsider using the\n[trusted proxies middleware](https://github.com/fideloper/TrustedProxy).\nIf you're using Symfony, just use `setTrustedProxies()` on your\n`Request` object, and Symfony takes care of the rest.  Note that\n`X-Base-Url` is not supported by either framework, so you'll need to\nadd a bit of custom code there if you need to override the base URL.\n\n\n## Changelog\n\n- 0.5.0 Add support for `nginx_extra_config` setting (Fixes ticket #8).\n- 0.4.0 Add support for `vagrant reload`, add support for host-based instead\n  of location-based dispatching (both thanks to Sam Stevens). NOTE: This is a\n  backwards incompatible change: the default name of the config file has\n  changed, so you must update the `include` statement in your NGINX config.\n- 0.3.1 Allow overriding the NGINX reload command (thanks to Sam Stevens).\n- 0.3 Allow overriding the location of the NGINX configuration file\n  (thanks to Sam Stevens).  Support multiple VMs in a single Vagrant\n  config (suggested by Nicholas Alipaz).\n- 0.2 Support for proxying of multiple ports in `vhosts` config.\n- 0.1 First version\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeyellowbv%2Fvagrant-reverse-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeyellowbv%2Fvagrant-reverse-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeyellowbv%2Fvagrant-reverse-proxy/lists"}