{"id":18035960,"url":"https://github.com/mr-bossman/nginxcraft-nginx-module","last_synced_at":"2025-04-04T23:25:52.369Z","repository":{"id":236684384,"uuid":"792972467","full_name":"Mr-Bossman/nginxcraft-nginx-module","owner":"Mr-Bossman","description":"nginxcraft - Nginx module to Proxy Minecraft servers","archived":false,"fork":false,"pushed_at":"2024-05-06T18:29:59.000Z","size":57,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-10T08:12:53.805Z","etag":null,"topics":["minecraft","minecraft-server","nginx","nginx-module","nginx-proxy","proxy","reverse-proxy"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mr-Bossman.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-28T04:16:42.000Z","updated_at":"2025-01-06T07:53:45.000Z","dependencies_parsed_at":"2024-10-30T19:15:35.459Z","dependency_job_id":null,"html_url":"https://github.com/Mr-Bossman/nginxcraft-nginx-module","commit_stats":null,"previous_names":["mr-bossman/parse_server_name-nginx-module","mr-bossman/nginxcraft-nginx-module"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mr-Bossman%2Fnginxcraft-nginx-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mr-Bossman%2Fnginxcraft-nginx-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mr-Bossman%2Fnginxcraft-nginx-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mr-Bossman%2Fnginxcraft-nginx-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mr-Bossman","download_url":"https://codeload.github.com/Mr-Bossman/nginxcraft-nginx-module/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247264090,"owners_count":20910519,"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":["minecraft","minecraft-server","nginx","nginx-module","nginx-proxy","proxy","reverse-proxy"],"created_at":"2024-10-30T12:11:02.825Z","updated_at":"2025-04-04T23:25:52.351Z","avatar_url":"https://github.com/Mr-Bossman.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Name\n====\n\n**nginxcraft-nginx-module** - Nginx module to reverse proxy Minecraft servers on layer 7\n\n*This module is not distributed with the Nginx source.* See [the installation instructions](#installation).\n\nTable of Contents\n=================\n\n* [Name](#name)\n* [Synopsis](#synopsis)\n* [Description](#description)\n* [Content Handler Directives](#content-handler-directives)\n    * [nginxcraft](#nginxcraft)\n    * [nginxcraft_return](#nginxcraft_return)\n* [Variables](#variables)\n    * [$minecraft_server](#minecraft_server)\n    * [$minecraft_version](#minecraft_version)\n    * [$minecraft_port](#minecraft_port)\n* [Installation](#installation)\n* [Compatibility](#compatibility)\n* [Source Repository](#source-repository)\n* [TODO](#todo)\n\n\nSynopsis\n========\n\n```nginx\n\nstream {\n\tlog_format\tmain\t'$remote_addr \"$server_name\" $minecraft_server $new_server \"$minecraft_port\" $minecraft_version';\n\taccess_log\tlogs/access.log\tmain;\n\terror_log\tlogs/debug.log\tdebug;\n\n\tupstream google {\n\t\tserver\tgoogle.com:80;\n\t}\n\n\tmap $minecraft_server $new_server {\n\t\t# Send to \"disconnect\" server if not in list\n\t\tdefault\tunix:/tmp/nginx_disconnect.sock;\n\t\t\"\"\t\tgoogle; # for when packet doesn't match a minecraft server\n\t}\n\n\tserver {\n\t\t# Hacky way to map to another server\n\t\tlisten\t\t\t\tunix:/tmp/nginx_disconnect.sock;\n\t\tserver_name\t\t\tdisconnect;\n\t\tnginxcraft_return\t\"{'color':'red','text':'You can not connect from: $minecraft_server'}\";\n\t}\n\n\tserver {\n\t\t# Will match if no other server matches\n\t\tlisten\t\t25565 default_server;\n\t\tserver_name\t_;\n\t\tproxy_pass\t$new_server;\n\t}\n\n\tserver {\n\t\t# Will match if url matches because nginxcraft is on\n\t\tlisten\t\t25565;\n\t\tserver_name\tlocal.example.com;\n\t\tnginxcraft\ton;\n\t\tproxy_pass\tmc.hypixel.net:25565;\n\t}\n\n\tserver {\n\t\t# Will not match because nginxcraft is off\n\t\tlisten\t\t25565;\n\t\tserver_name\tlocal.sample.com;\n\t\tproxy_pass\tmc.hypixel.net:25565;\n\t}\n}\n```\n\n[Back to TOC](#table-of-contents)\n\nDescription\n===========\n\n**Important notes**:\n\n1. Minecraft has compressed format, documented [here](https://wiki.vg/Protocol#With_compression),\n\tbut is [optionally requested](https://wiki.vg/Protocol#Disconnect_.28login.29) by the server, so it is unnecessary to consider.\n\n[Back to TOC](#table-of-contents)\n\nContent Handler Directives\n==========================\n\nnginxcraft\n----\n**syntax:** *nginxcraft \\[on;off\\]*\n\n**default:** *no*\n\n**context:** *server*\n\n**phase:** *preread*\n\n```nginx\n\tserver {\n\t\tlisten\t\t25565;\n\t\tserver_name\tlocal.example.com;\n\t\tnginxcraft\ton;\n\t\tproxy_pass\tmc.hypixel.com:25565;\n\t}\n```\n\n[Back to TOC](#table-of-contents)\n\nnginxcraft_return\n----\n**syntax:** *nginxcraft_return  \u0026lt;string\u0026gt;*\n\n**default:** *no*\n\n**context:** *server*\n\n**phase:** *content*\n\nSends string in to client encoded in Minecraft's [Disconnect Packet](https://wiki.vg/Protocol#Disconnect_.28login.29) format\nthen terminates the connection.\n\n```nginx\n\tserver {\n\t\tlisten\t\t25565;\n\t\tserver_name\tlocal.example.com;\n\t\tnginxcraft_return\t\"{'text':'You can not connect from: $minecraft_server'}\";\n\t}\n```\n\n[Back to TOC](#table-of-contents)\n\nVariables\n=========\n\n$minecraft_server\n-------------------\n\nThis variable holds the Minecraft server name.\n\n[Back to TOC](#table-of-contents)\n\n$minecraft_version\n-------------------\n\nThis variable holds the Minecraft client verison.\n\n[List of protocol version numbers](https://wiki.vg/Protocol_version_numbers)\n\n[Back to TOC](#table-of-contents)\n\n$minecraft_port\n-------------------\n\nThis variable holds the port used to connect in the handshake packet.\n\n[Handshake packet reference](https://wiki.vg/Protocol#Handshake)\n\n[Back to TOC](#table-of-contents)\n\nInstallation\n============\n\nGrab the nginx source code from [nginx.org](http://nginx.org/), for example,\nthe version 1.25.5 (see [nginx compatibility](#compatibility)), and then build the source with this module:\n\n```bash\n\n $ wget 'http://nginx.org/download/nginx-1.25.5.tar.gz'\n $ tar -xzvf nginx-1.25.5.tar.gz\n $ cd nginx-1.25.5/\nc\n # Here we assume you would install you nginx under /usr/local/nginx/.\n $ ./configure --prefix=/usr/local/nginx/ --with-stream \\\n     \t --add-module=/path/to/nginxcraft-nginx-module\n\n $ make -j$(nproc)\n $ make install\n```\n\nStarting from NGINX 1.9.11, you can also compile this module as a dynamic module, by using the `--add-dynamic-module=PATH` option instead of `--add-module=PATH` on the\n`./configure` command line above.\nIf Nginx was build with `--with-compat` you will not need to specify the exact same compilation\noptions to ./configure that the main NGINX binary was compiled with. You can check with `nginx -V 2\u003e\u00261 | grep --color=always -- --with-compat`.\nTo make just the module run `make modules`.\nThen you can explicitly load the module in your `nginx.conf` via the [load_module](http://nginx.org/en/docs/ngx_core_module.html#load_module)\ndirective, for example,\n\n```nginx\nload_module /path/to/modules/ngx_stream_nginxcraft_module.so;\n```\n\n[Back to TOC](#table-of-contents)\n\nCompatibility\n=============\n\nThe following versions of Nginx should work with this module:\n\n* **1.25.5**                       (last tested: 1.25.5)\n\nNGINX versions older than 1.25.5 will *not* work due to the lack of support for multiple \"stream\" server directives.\n\n[Back to TOC](#table-of-contents)\n\nSource Repository\n=================\n\nAvailable on github at [Mr-Bossman/nginxcraft-nginx-module](https://github.com/Mr-Bossman/nginxcraft-nginx-module).\n\n[Back to TOC](#table-of-contents)\n\nTODO\n====\n* Finish [Synopsis](#synopsis) and [Description](#description)\n* Should we be using PREREAD phase?\n* Attribute the readme template\n* Fix ngx_str_snprintf\n* **Fix my life**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-bossman%2Fnginxcraft-nginx-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmr-bossman%2Fnginxcraft-nginx-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-bossman%2Fnginxcraft-nginx-module/lists"}