[
  {
    "path": ".gitmodules",
    "content": "[submodule \"public/wombat\"]\n\tpath = public/wombat\n\turl = https://github.com/webrecorder/wombat\n"
  },
  {
    "path": ".replit",
    "content": "language=\"nix\"\nrun = \"./replit-run.sh\""
  },
  {
    "path": "Dockerfile",
    "content": "FROM node:16-alpine as builder\n\n# build wombat\nRUN apk add git python3 make gcc musl-dev libc-dev g++\nCOPY . /opt/womginx\n\nWORKDIR /opt/womginx\n# for whatever reason, heroku doesn't copy the .git folder and the .gitmodules file, so we're\n# approaching this assuming they will never exist\nRUN rm -rf .git && git init\nWORKDIR /opt/womginx/public\nRUN rm -rf wombat && git submodule add https://github.com/webrecorder/wombat\nWORKDIR /opt/womginx/public/wombat\n# wombat's latest version (as of January 4th, 2022; commit 72db794) breaks websocket functionality.\n# Locking the version here temporarily until I can find a solution\nRUN git checkout 78813ad\n\nRUN npm install --legacy-peer-deps && npm run build-prod\n\n# delete everything but the dist folder to save us an additional 50MB+\nRUN mv dist .. && rm -rf * .git && mv ../dist/ .\n\n# modify nginx.conf\nWORKDIR /opt/womginx\n\nRUN ./docker-sed.sh\n\nFROM nginx:stable-alpine\n\n# default environment variables in case a normal user doesn't specify it\nENV PORT=80\n# set SAFE_BROWSING to any value to enable it\n#ENV SAFE_BROWSING=1\n\nCOPY --from=builder /opt/womginx /opt/womginx\nRUN cp /opt/womginx/nginx.conf /etc/nginx/nginx.conf\n\n# make sure nginx.conf works (mainly used for development)\nRUN nginx -t\n\nCMD /opt/womginx/docker-entrypoint.sh\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU AFFERO GENERAL PUBLIC LICENSE\n                       Version 3, 19 November 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU Affero General Public License is a free, copyleft license for\nsoftware and other kinds of works, specifically designed to ensure\ncooperation with the community in the case of network server software.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nour General Public Licenses are intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  Developers that use our General Public Licenses protect your rights\nwith two steps: (1) assert copyright on the software, and (2) offer\nyou this License which gives you legal permission to copy, distribute\nand/or modify the software.\n\n  A secondary benefit of defending all users' freedom is that\nimprovements made in alternate versions of the program, if they\nreceive widespread use, become available for other developers to\nincorporate.  Many developers of free software are heartened and\nencouraged by the resulting cooperation.  However, in the case of\nsoftware used on network servers, this result may fail to come about.\nThe GNU General Public License permits making a modified version and\nletting the public access it on a server without ever releasing its\nsource code to the public.\n\n  The GNU Affero General Public License is designed specifically to\nensure that, in such cases, the modified source code becomes available\nto the community.  It requires the operator of a network server to\nprovide the source code of the modified version running there to the\nusers of that server.  Therefore, public use of a modified version, on\na publicly accessible server, gives the public access to the source\ncode of the modified version.\n\n  An older license, called the Affero General Public License and\npublished by Affero, was designed to accomplish similar goals.  This is\na different license, not a version of the Affero GPL, but Affero has\nreleased a new version of the Affero GPL which permits relicensing under\nthis license.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU Affero General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Remote Network Interaction; Use with the GNU General Public License.\n\n  Notwithstanding any other provision of this License, if you modify the\nProgram, your modified version must prominently offer all users\ninteracting with it remotely through a computer network (if your version\nsupports such interaction) an opportunity to receive the Corresponding\nSource of your version by providing access to the Corresponding Source\nfrom a network server at no charge, through some standard or customary\nmeans of facilitating copying of software.  This Corresponding Source\nshall include the Corresponding Source for any work covered by version 3\nof the GNU General Public License that is incorporated pursuant to the\nfollowing paragraph.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the work with which it is combined will remain governed by version\n3 of the GNU General Public License.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU Affero General Public License from time to time.  Such new versions\nwill be similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU Affero General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU Affero General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU Affero General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Affero General Public License as published\n    by the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Affero General Public License for more details.\n\n    You should have received a copy of the GNU Affero General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If your software can interact with users remotely through a computer\nnetwork, you should also make sure that it provides a way for users to\nget its source.  For example, if your program is a web application, its\ninterface could display a \"Source\" link that leads users to an archive\nof the code.  There are many ways you could offer source, and different\nsolutions will be better for different programs; see section 13 for the\nspecific requirements.\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU AGPL, see\n<https://www.gnu.org/licenses/>.\n"
  },
  {
    "path": "README.md",
    "content": "# Womginx\n\n> Fastest proxy using only nginx as the backend server\n\n<a href=\"https://repl.it/github/binary-person/womginx\"><img src=\"https://docs.replit.com/images/repls/run-on-replit.svg\" alt=\"Replit\" width=\"150\"/></a>\n\n**Before you deploy to Heroku, read the following: Heroku decided that this repository violates the ToS, so directly clicking the button below if you're in the main repository will result in an error. Forked repositories may work, though this is not guaranteed. Regardless, I am NOT responsible if your Heroku account gets suspended because of deploying this application. Proceed at your own risk.**\n\n[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)\n\nDemo: https://womginx.arph.org\n\n~~Heroku Docker demo: https://womginx.herokuapp.com~~ taken down for now. If you need one, deploy one using the button above or use the demo link.\n\n## Site compatibility\n\nWhat works:\n1. recaptcha\n2. discord with actual login credentials (no qr code required)\n3. websocket sites\n4. sites that have cookies\n\nWhat doesn't work:\n1. react sites\n2. sites that depend on window.location and are minified\n3. YouTube UI (however, you can watch a video like https://proxysite.com/main/https://www.youtube.com/watch?v=vidid and it will work)\n\n## Prerequisites\n\nYou need one thing and one thing only: nginx.\n\nOk maybe not just that, you'll need the following:\n1. nginx\n2. certbot\n3. nodejs (for building wombat)\n4. a (sub)domain\n5. a vps\n\n## Installation (more simple and contained)\n\n1. [Install Docker](https://docs.docker.com/engine/install/ubuntu/)\n2. [Install docker-compose](https://docs.docker.com/compose/install/)\n3. Clone this repo by running `git clone https://github.com/binary-person/womginx`\n4. `cd womginx` then edit go and edit `docker-compose.yml`\n    - To disable safe browsing, delete the line that says `SAFE_BROWSING`\n    - To change the port, edit `80:80` to `newport:80`\n    - Don't pay attention to `PORT=80` as changing that only changes the port inside the docker container. Only weird environments like Heroku need it.\n    - To bind the port locally, do `127.0.0.1:80:80` (do this if you're hosting multiple things and you're using a reverse proxy like nginx or caddy)\n    - If you are using a reverse proxy, set the `x-forwarded-for` as womginx's rate limiter relies on this header when running in a container. So for nginx, add `proxy_set_header X-Forwarded-For $remote_addr;`\n5. then run `sudo docker-compose up -d` to start it\n6. `sudo docker-compose down` to stop\n7. If you want to update womginx to the latest version, run `git pull && sudo docker-compose up -d --build`\n\n## Installation (more complex, direct, and permanent)\n\n```bash\n# assuming you are on Ubuntu/Debian\n\n## Part 1 of installation ##\n\n# update your repo list\nsudo apt update\n\n# 1. install nginx\nsudo apt install nginx\n\n# 2. install certbot and the nginx plugin\nsudo apt install certbot python3-certbot-nginx\n\n# 3. install nodejs (skip if you already have it)\ncurl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -\nsudo apt-get install nodejs\n\n# 4. Get a (sub)domain with an A(AAA) record pointing to your VPS IP\n\n# 5. Get an ssl certificate\nsudo certbot --nginx certonly -n -d yourdomain.com\n\n## Part 2 of installation ##\n\n# 1. clone repo and wombat submodule\ngit clone --recursive https://github.com/binary-person/womginx\n\n# 2. build wombat\ncd womginx/public/wombat\nnpm install\nnpm run build-prod\n\n# 3. replace 'womginx.arph.org' with 'yourdomain.com' in nginx.conf\ncd .. # cd into public folder\nsed -i -e 's/womginx.arph.org/yourdomain.com/g' ../nginx.conf\n\n# 4. replace '/home/binary/womginx/public' with your public folder\nsed -i -e \"s/\\/home\\/binary\\/womginx\\/public/$(pwd | sed -e 's/\\//\\\\\\//g')/g\" ../nginx.conf\n\n# 5. make backup of original nginx.conf\nsudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup\n\n# 6. copy womginx nginx.conf to /etc/nginx/nginx.conf\nsudo cp ../nginx.conf /etc/nginx/nginx.conf\n\n# 7. restart the nginx server\nsudo service nginx restart\n```\n\n## Why did you want to use only nginx and burden yourself with nginx's \"restrictive\" and \"esoteric\" config?\n\nI did it as a game, or, challenge, for myself to learn nginx and also to take advantage of nginx's resilience and speed for handling lots of requests, which is perfect for proxying.\n\nIt also was to deter nginx's restrictive reputation (in a community server I'm in).\n\n## Contributing\n\nContributions are welcome. Send in a pull request and I'll be more than happy to take a look.\n\n## Future plans\n\nMake another client rewriting library similar to wombat but made with intent to be a proxy rewriting library and with the goal of ease of use for the server and the client.\n\n## License\n\nThis project is licensed under the AGPL license.\n\nWombat uses AGPL, and under the terms of that license, this project, therefore, is also required to be licensed under AGPL.\n\n## Credits\n\n- Front page design by [voept](https://github.com/voept)\n- Logo design by [kinglalu](https://github.com/kinglalu)\n"
  },
  {
    "path": "app.json",
    "content": "{\n    \"name\": \"Womginx\",\n    \"description\": \"Fastest proxy using only nginx as the backend server\",\n    \"repository\": \"https://github.com/binary-person/womginx\",\n    \"logo\": \"https://raw.githubusercontent.com/binary-person/womginx/master/public/logo.png\",\n    \"keywords\": [\n        \"nginx\",\n        \"docker\"\n    ],\n    \"stack\": \"container\",\n    \"env\": {\n        \"SAFE_BROWSING\": {\n            \"description\": \"Unset this value to disable. However, if this option is set, then the dns server is set to 1.1.1.3, which blocks malware and adult content. See https://1.1.1.1/family/ for more info\",\n            \"value\": \"1\",\n            \"required\": false\n        }\n    }\n}"
  },
  {
    "path": "docker-compose.yml",
    "content": "version: \"2.1\"\nservices:\n  womginx:\n    build: .\n    container_name: womginx\n    environment:\n      - PORT=80\n      - SAFE_BROWSING=1\n    ports:\n      - 80:80\n    restart: unless-stopped\n"
  },
  {
    "path": "docker-entrypoint.sh",
    "content": "#!/bin/sh\n\nset -e\n\n# environment variables are set at runtime, so modify the conf only when it starts\nsed -i \"s/listen 80/listen $PORT/\" /etc/nginx/nginx.conf\n\nif [ ! -z \"$SAFE_BROWSING\" ]; then\n    sed -i \"s/1.1.1.1/1.1.1.3/\" /etc/nginx/nginx.conf\nfi\n\n\n# default.conf makes docker listen to 80, and\n# heroku's non-root user running this won't like it at all\nrm /etc/nginx/conf.d/default.conf\n\nnginx\n"
  },
  {
    "path": "docker-sed.sh",
    "content": "#!/bin/sh\n\nset -e\n\n# change public dir to appropriate path\nsed -i \"s/\\/home\\/binary\\/womginx\\/public/\\/opt\\/womginx\\/public/g\" nginx.conf\n\n# disable ssl (since we're running this behind a reverse proxy like heroku)\nsed -i '/ssl_certificate/d' nginx.conf\nsed -i '/listen 443/d' nginx.conf\n\n# prevent reverse proxy headers from being sent to destination site (heroku headers, for example)\nsed -i $\"s/proxy_set_header Accept-Encoding/proxy_set_header x-request-id '';\\\nproxy_set_header x-forwarded-for '';\\\nproxy_set_header x-forwarded-proto '';\\\nproxy_set_header x-forwarded-port '';\\\nproxy_set_header via '';\\\nproxy_set_header connect-time '';\\\nproxy_set_header x-request-start '';\\\nproxy_set_header total-route-time '';\\\nproxy_set_header Accept-Encoding/\" nginx.conf\n\n# use x-forwarded-for instead of remote client ip since client ip would be our reverse proxy's, not our\n# client's (heroku, for example)\nsed -i \"s/binary_remote_addr/http_x_forwarded_for/g\" nginx.conf\n\n# pipe logs to stdout/stderr instead of the default /var/log/nginx/ location\nsed -i 's/http {/http {access_log \\/dev\\/stdout; error_log stderr;/' nginx.conf\n\n# disable daemon mode for nginx\nsed -i '1i daemon off;' nginx.conf"
  },
  {
    "path": "heroku.yml",
    "content": "build:\n  docker:\n    web: Dockerfile"
  },
  {
    "path": "nginx.conf",
    "content": "user nginx nginx;\nworker_processes auto;\npid /run/nginx.pid;\ninclude /etc/nginx/modules-enabled/*.conf;\n\nevents {\n    worker_connections 1024;\n}\n\nhttp {\n    include /etc/nginx/mime.types;\n    include /etc/nginx/conf.d/*; # add any additional/custom server blocks\n    map_hash_bucket_size 128;\n\n    resolver 1.1.1.1;\n    # resolver 1.1.1.3; # <-- uncomment this and comment out the above to block malware and adult sites\n\n    # ddos protection\n    client_body_timeout 10s;\n    client_header_timeout 10s;\n    proxy_connect_timeout 20s;\n    # these are very lenient limits. there should be no reason why a\n    # client will request 60 requests per second for a straight 8.33 seconds\n    limit_req_zone $binary_remote_addr zone=limitreq:20m rate=30r/s;\n    limit_req zone=limitreq burst=500 nodelay;\n    limit_req_status 429;\n    limit_conn_zone $binary_remote_addr zone=limitconn:20m;\n    limit_conn limitconn 50;\n\n    # domain blacklist. blacklisting www.example.com as an example\n    map $dest_host $blacklist {\n        default 0;\n        'www.example.com' 1;\n    }\n    # blacklist user agents\n    # the following is a default list that simply blocks all bots. credit to https://stackoverflow.com/a/24820722\n    map $http_user_agent $blacklist_useragent {\n        default 0;\n        ~*(google|bing|yandex|msnbot) 1;\n        ~*(AltaVista|Googlebot|Slurp|BlackWidow|Bot|ChinaClaw|Custo|DISCo|Download|Demon|eCatch|EirGrabber|EmailSiphon|EmailWolf|SuperHTTP|Surfbot|WebWhacker) 1;\n        ~*(Express|WebPictures|ExtractorPro|EyeNetIE|FlashGet|GetRight|GetWeb!|Go!Zilla|Go-Ahead-Got-It|GrabNet|Grafula|HMView|Go!Zilla|Go-Ahead-Got-It) 1;\n        ~*(rafula|HMView|HTTrack|Stripper|Sucker|Indy|InterGET|Ninja|JetCar|Spider|larbin|LeechFTP|Downloader|tool|Navroad|NearSite|NetAnts|tAkeOut|WWWOFFLE) 1;\n        ~*(GrabNet|NetSpider|Vampire|NetZIP|Octopus|Offline|PageGrabber|Foto|pavuk|pcBrowser|RealDownload|ReGet|SiteSnagger|SmartDownload|SuperBot|WebSpider) 1;\n        ~*(Teleport|VoidEYE|Collector|WebAuto|WebCopier|WebFetch|WebGo|WebLeacher|WebReaper|WebSauger|eXtractor|Quester|WebStripper|WebZIP|Wget|Widow|Zeus) 1;\n        ~*(Twengabot|htmlparser|libwww|Python|perl|urllib|scan|Curl|email|PycURL|Pyth|PyQ|WebCollector|WebCopy|webcraw) 1;\n    }\n    # set scheme appropriately in case nginx is sitting behind servers like heroku\n    map $http_x_forwarded_proto $relativescheme {\n        default $http_x_forwarded_proto;\n        '' $scheme;\n    }\n\n    # websocket headers\n    map $http_upgrade $connection_upgrade {\n        default Upgrade;\n        '' close;\n    }\n\n    map '' $proxy_prefix {\n        default $relativescheme://$host;\n    }\n\n    map $targeturl $dest_host {\n        default '';\n        ~^https?://([^/]+) $1;\n    }\n    # remove origin header from websocket url request: wss://dest:12/blah?somestuff?womginx_ws_origin_header=https://example.com\n    # convert wss://domain.com to https://domain.com\n    map $targeturl $dest_fullwebsocketurl {\n        default $targeturl;\n        ~^ws(s)?://(.+)(\\?womginx_ws_origin_header=.+)$ http$1://$2;\n        ~^ws(s)?://(.+) http$1://$2;\n    }\n    # get targeturl destination from referrer\n    map $http_referer $dest_referrerhost {\n        default '';\n        ~^https?://[^/]+/main(/[^_/]+_)?/(?<targeturl>https?://?[^/]+) $targeturl;\n    }\n    # use $request_uri for proxy cookie rewriting where there is no $targeturl variable\n    map $request_uri $dest_hostwithscheme {\n        default '';\n        ~^/main(/[^_/]+_)?/(https?://?[^/]+) $2;\n    }\n    # header rewrites\n    map $http_referer $rewrite_referer {\n        default $http_referer;\n        ~^https?://[^/]+/main(/[^_/]+_)?/(?<targeturl>.*) $targeturl;\n    }\n    # rewrite origin header with destination host. if that doesn't exist, don't rewrite it\n    # also, get origin header from websocket request, prioritizing over $http_origin if that exists (see $dest_fullwebsocketurl)\n    map $http_origin:womginxseparate:$request_uri $rewrite_origin {\n        default $dest_hostwithscheme;\n        # origin maybe exists, womginx_ws_origin_header exists\n        ~^.+(\\?womginx_ws_origin_header=(.+))$ $2;\n        # origin and womginx_ws_origin_header doesn't exist\n        ~^:womginxseparate: '';\n    }\n    # womginx_ws_origin_header contain merged slashes from wombat-handler.js to avoid the middle server closing\n    # the websocket connection because of the need to merge it. this is to undo that\n    map $rewrite_origin $reslashed_origin {\n        default $rewrite_origin;\n        ~^(https?:/)([^/].*) $1/$2;\n    }\n    server {\n        server_name womginx.arph.org;\n\n        listen 80;\n        listen 443 ssl;\n        ssl_certificate /etc/letsencrypt/live/womginx.arph.org/fullchain.pem;\n        ssl_certificate_key /etc/letsencrypt/live/womginx.arph.org/privkey.pem;\n\n        merge_slashes off;\n        proxy_ssl_server_name on;\n        error_page 404 = @referrer-handler;\n\n        # reason for putting rewrites here is putting them in parent of nested locations will\n        # not apply to child locations\n        # use undecoded uri as location for proxying encoded urls\n        rewrite ^ $request_uri;\n\n        # convert /main/http:/google.com to /main/http://google.com internally without redirect\n        # because some services like repl.it force-merge double slashes\n        # (this is handled together with wombat-handler.js)\n        rewrite ^\\/main(?<mod>\\/[^\\/_]+_)?(?<url_preslash>\\/(?:http|ws)s?:\\/)(?<url_postslash>[^\\/].*) /main$mod$url_preslash/$url_postslash;\n\n        # convert /main/http://domain.com to /main/http://domain.com/\n        # convert /main/http://domain.com?a to /main/http://domain.com/?a\n        rewrite ^(/main/https?://[^/?]*)/?(.*) $1/$2;\n\n        set $womginx_cookie 'womginx_are_you_a_bot=no; Path=/; HttpOnly';\n        \n        # Seemlessly add womginx cookie to improve user experience. Cookies sometimes get unset by\n        # the proxy site server so it is confusing when the 403 error pops up. Also, going to / to set cookie\n        # wouldn't necessarily work since the browser caches the page but doesn't actually set the required cookie.\n        # example url: /womginxaddcookie/timestamp_for_cache_busting/https://womginxserver/main/https://www.google.com \n        location ~^/womginxaddcookie/\\d+/(.+) {\n            add_header Set-Cookie $womginx_cookie;\n            return 302 $1;\n        }\n\n        #### static file requests handling ####\n\n        # serve static files, disallow access to .git directories, and ignore prefixes starting with /main/\n        location ~^((?!/\\.git|^/main/).)*$ {\n            add_header 'Set-Cookie' $womginx_cookie;\n            alias /home/binary/womginx/public$uri;\n            # if no file is found, pass it to @referrer-handler\n        }\n        location = / {\n            if ($dest_referrerhost = '') {\n                rewrite ^ /index.html last;\n            }\n            # if no file exists, pass it to @referrer-handler\n            return 404;\n        }\n        # catch links like '/assets.png' and redirect them by their referrer if referrer is valid\n        location @referrer-handler {\n            # if referrer doesn't exist, send 404 page\n            if ($dest_referrerhost = '') {\n                return 404;\n            }\n            # if it exists, send appropriate redirection\n            return 302 $proxy_prefix/main/$dest_referrerhost$request_uri;\n        }\n\n\n        #### proxy requests handling ####\n        location /main {\n            # reason for including all proxy header modifications here is because apparently,\n            # using proxy_set_header in a child block automatically negates all parent proxy_set_header\n            # directives.\n            # disable disabling inline scripts (if proxy sends a content-security-policy like that over)\n            proxy_hide_header Content-Security-Policy;\n            # force proxy to send non-compressed for sub_filter to work\n            proxy_set_header Accept-Encoding 'identity;q=1, *;q=0';\n            # prevent proxied servers' HSTS headers from affecting the client\n            proxy_hide_header Strict-Transport-Security;\n            # enable support for embedding proxy site in an iframe\n            proxy_hide_header X-Frame-Options;\n            # rewrite referer header\n            proxy_set_header Referer $rewrite_referer;\n            # rewrite origin header\n            proxy_set_header Origin $reslashed_origin;\n            # rewrite cookie domain and path\n            proxy_cookie_domain ~(.*) $host;\n            # rewrite cookie path\n            proxy_cookie_path ~(/.*) /main/$dest_hostwithscheme$1;\n            # websocket headers\n            proxy_set_header Upgrade $http_upgrade;\n            proxy_set_header Connection $connection_upgrade;\n            # fix \"upstream sent too big header/body\"\n            proxy_buffer_size 16k;\n            # proxy_buffer_size + 8k\n            proxy_busy_buffers_size 24k;\n            # numOfBuffers * bufferSize >= proxy_buffer_size\n            proxy_buffers 4 16k; \n            # client can only upload files less than 100M\n            client_max_body_size 100M;\n\n            # rewrite relative urls like /main/// to /main/https:// internally without redirect\n            location ~^/main(/[^_/]+_)?///(?<protocol_relative_url>.+) {\n                rewrite ^/main(/[^_/]+_)?///(?<protocol_relative_url>.+) /main$1/$relativescheme://$protocol_relative_url last;\n            }\n            # redirect any url with /main/google.com to /main/https://google.com\n            location ~^/main(/[^/_]+_)?(?!(/[^/_]+_)?/(http|ws)s?://|//)/(?<rewrite_url_with_scheme>.*) {\n                return 302 $proxy_prefix/main$1/$relativescheme://$rewrite_url_with_scheme;\n            }\n            # handle websocket connections\n            location ~^/main/\\d*ws_/(?<targeturl>.+){\n                proxy_http_version 1.1;\n                \n                proxy_pass $dest_fullwebsocketurl;\n            }\n            # serve assets\n            location ~^/main/\\d*(im|oe)_/(?<targeturl>.+) {\n                proxy_pass $targeturl;\n            }\n            # serve web and service workers. rewrites are done client side\n            location ~^/main/\\d*(wkr|sw)_/(?<targeturl>.+) {\n                proxy_pass $targeturl;\n            }\n            # rewrite js files\n            location ~^/main/\\d*js_/(?<targeturl>.+) {\n                sub_filter_once off;\n                sub_filter_types *;\n                sub_filter '.postMessage(' '.__WB_pmw(self.window).postMessage(';\n                sub_filter '.postMessage (' '.__WB_pmw(self.window).postMessage (';\n                sub_filter 'window.location' 'window.currentLocation';\n                proxy_pass $targeturl;\n            }\n            # redirect any url with /main/unsupportedmod_/blahblah to /main/blahblah\n            location ~^/main/[^_/]+_/(?<redirecttargeturl>.+) {\n                return 302 $proxy_prefix/main/$redirecttargeturl;\n            }\n            location ~^/main/(?<targeturl>.*)$ {\n                # blacklist urls\n                if ($blacklist) {\n                    return 403 'Sorry. The owner of this proxy decided to disallow access to this content.';\n                }\n                # blacklist user agents\n                if ($blacklist_useragent) {\n                    return 403 'Sorry, you are not allowed to access this content.';\n                }\n                # deny access to anyone without the special cookie, but redirect them appropriately to set it\n                if ($cookie_womginx_are_you_a_bot != 'no') {\n                    add_header Content-Type text/html always;\n                    return 403 '<script>location.href=\"/womginxaddcookie/\"+Date.now()+\"/\"+location.href</script>';\n                }\n\n                # handle proxy sending redirection requests\n                proxy_redirect ~^(https?://.+) $proxy_prefix/main/$1;\n\n                sub_filter_once off;\n                # sub_filter_types text/html; already text/html by default but leaving it here for clarity\n                # and commenting it out to suppress duplicate warnings\n\n\n                # wrap href,src,poster,action,srcset,data,codebase links.\n                # and add a womginx-processed attribute to the tag to notify client js it is already handled.\n                # since we're not using subs_filter module for simplicity of installation, we are going to\n                # list every possible combination. However, we only need to do src and script src tags\n                # because they cannot be handled by wombat, and for the rest of the attributes, we can\n                # let the client handle it for offloading the CPU load to the client and maintaining\n                # the integrity of the html document (so we reduce chances of replacing an attribute at a\n                # wrong place)\n\n                set $processed_flag_attribute 'womginx-processed';\n                # 1. change 'href=\"//domain/image.png' to 'womginx-processed href=\"/main/$relativescheme://domain/image.png'\n                # for scripts, serve under /main/js_/http://domain.com/script.js to inject wombat code\n                sub_filter '<script src=\"//' '<script $processed_flag_attribute src=\"/main/js_/$relativescheme://';\n                sub_filter '<script type=\"text/javascript\" src=\"//' '<script type=\"text/javascript\" $processed_flag_attribute src=\"/main/js_/$relativescheme://';\n                sub_filter 'src=\"//' '$processed_flag_attribute src=\"/main/$relativescheme://';\n                \n                # 2. change 'href=\"/image.png' to 'womginx-processed href=\"/main/$dest_hostwithscheme/image.png'\n                sub_filter '<script src=\"/' '<script $processed_flag_attribute src=\"/main/js_/$dest_hostwithscheme/';\n                sub_filter '<script type=\"text/javascript\" src=\"/' '<script type=\"text/javascript\" $processed_flag_attribute src=\"/main/js_/$dest_hostwithscheme/';\n                sub_filter 'src=\"/' '$processed_flag_attribute src=\"/main/$dest_hostwithscheme/';\n\n                # 3. change 'href=\"https://domain.com/image.png\"' to 'womginx-processed href=\"/main/https://domain.com/image.png\"'\n                sub_filter '<script src=\"https://' '<script $processed_flag_attribute src=\"/main/js_/https://';\n                sub_filter '<script type=\"text/javascript\" src=\"https://' '<script type=\"text/javascript\" $processed_flag_attribute src=\"/main/js_/https://';\n                sub_filter 'src=\"https://' '$processed_flag_attribute src=\"/main/https://';\n\n                # 4. same as above but with http:// instead of https://\n                sub_filter '<script src=\"http://' '<script $processed_flag_attribute src=\"/main/js_/http://';\n                sub_filter '<script type=\"text/javascript\" src=\"http://' '<script type=\"text/javascript\" $processed_flag_attribute src=\"/main/js_/http://';\n                sub_filter 'src=\"http://' '$processed_flag_attribute src=\"/main/http://';\n\n                # 5. rewrite 'integrity=\"' to 'nointegrity=' to disable script integrity checking\n                sub_filter 'integrity=\"' 'nointegrity=\"';\n\n                # 6. disable meta tag's Content-Security-Policy\n                sub_filter 'http-equiv=\"Content-Security-Policy\"' 'http-equiv=\"No-U-Content-Security-Policy\"';\n\n                # do the same thing but instead of \", do '\n                # 1.\n                sub_filter \"<script src='//\" \"<script $processed_flag_attribute src='/main/js_/$relativescheme://\";\n                sub_filter \"<script type='text/javascript' src='//\" \"<script type='text/javascript' $processed_flag_attribute src='/main/js_/$relativescheme://\";\n                sub_filter \"src='//\" \"$processed_flag_attribute src='/main/$relativescheme://\";\n                # 2.\n                sub_filter \"<script src='/\" \"<script $processed_flag_attribute src='/main/js_/$dest_hostwithscheme/\";\n                sub_filter \"<script type='text/javascript' src='/\" \"<script type='text/javascript' $processed_flag_attribute src='/main/js_/$dest_hostwithscheme/\";\n                sub_filter \"src='/\" \"$processed_flag_attribute src='/main/$dest_hostwithscheme/\";\n                # 3.\n                sub_filter \"<script src='https://\" \"<script $processed_flag_attribute src='/main/js_/https://\";\n                sub_filter \"<script type='text/javascript' src='https://\" \"<script type='text/javascript' $processed_flag_attribute src='/main/js_/https://\";\n                sub_filter \"src='https://\" \"$processed_flag_attribute src='/main/https://\";\n                # 4.\n                sub_filter \"<script src='http://\" \"<script $processed_flag_attribute src='/main/js_/http://\";\n                sub_filter \"<script type='text/javascript' src='http://\" \"<script type='text/javascript' $processed_flag_attribute src='/main/js_/http://\";\n                sub_filter \"src='http://\" \"$processed_flag_attribute src='/main/http://\";\n                # 5.\n                sub_filter \"integrity='\" \"nointegrity='\";\n                # 6. disable meta tag's Content-Security-Policy\n                sub_filter \"http-equiv='Content-Security-Policy'\" \"http-equiv='No-U-Content-Security-Policy'\";\n\n\n                # insert wombat.js and wombat-handler.js scripts\n                sub_filter '<head>' '<head>\n    <script $processed_flag_attribute src=\"/wombat/dist/wombat.js\"></script>\n    <script $processed_flag_attribute src=\"/wombat-handler.js\" processed-attribute=\"$processed_flag_attribute\">\n    </script>';\n                proxy_pass $targeturl;\n            }\n        }\n    }\n}"
  },
  {
    "path": "public/index.css",
    "content": "body {\n    font-family: \"Ubuntu\";\n    font-size: \"25px\";\n    text-align: center;\n    background-color: #1c9a54;\n    background-repeat: no-repeat;\n    background-size: cover\n}\n\n.container {\n    margin-top: 10%;\n    font-family: \"Ubuntu\";\n    font-size: \"50px\";\n    color: #FFF;\n}\n\n.container p {\n    font-size: 50px;\n    margin-bottom: 2px;\n}\n\n#iurl {\n    background-color: inherit;\n    width: 100%;\n    height: 28px;\n    border: solid 1px #FFF;\n    font-family: \"Ubuntu\";\n    font-size: 16px;\n    color: #eee;\n    padding: 8px 0px;\n    margin-bottom: 5px;\n    box-sizing: content-box;\n    text-align: center;\n    border-radius: 2px;\n}\n\n#btn {\n    background-color: inherit;\n    width: 100%;\n    height: 28px;\n    border: solid 1px #0066ff;\n    font-family: \"Ubuntu\";\n    font-size: 16px;\n    color: #0066ff;\n    padding: 8px 0px;\n    box-sizing: content-box;\n    transition: 0.3s;\n    border-radius: 2px;\n}\n\n#btn:hover {\n    background: #0066ff;\n    color: #fff;\n    background-repeat: no-repeat;\n}\n\n.container a {\n    height: 20px;\n    background: inherit;\n    background-size: cover;\n    color: #ddd;\n    border: 0;\n    cursor: pointer;\n    font-family: \"Ubuntu\";\n    font-size: 17px;\n    transition: 0.3s;\n}\n\n.container a:hover {\n    font-size: 23;\n}\n\n.url {\n    width: 300px;\n    margin: auto;\n}"
  },
  {
    "path": "public/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n\n<head>\n    <meta charset=\"UTF-8\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n    <link href=\"https://fonts.googleapis.com/css2?family=Ubuntu&display=swap\" rel=\"stylesheet\">\n    <link href=\"https://fonts.googleapis.com/css2?family=Roboto&display=swap\" rel=\"stylesheet\">\n    <link href=\"https://fonts.googleapis.com/icon?family=Material+Icons\" rel=\"stylesheet\">\n    <link href=\"index.css\" rel=\"stylesheet\">\n    <link rel=\"stylesheet\" href=\"https://www.w3schools.com/w3css/4/w3.css\">\n    <link rel=\"shortcut icon\" type=\"image/png\" href=\"logo.png\" />\n    <title>NGINX Proxy</title>\n</head>\n\n<body>\n    <div class=\"container\">\n        <img src=\"logo-full.png\" width=\"250\" height=\"250\">\n        <div>\n            <script>\n                function go() {\n                    var input = document.getElementById('url-target');\n                    if (input.value) {\n                        window.location.href = '/main/' + input.value;\n                    } else {\n                        alert('Please provide a link. It does not require https://.');\n                    }\n                }\n            </script>\n            <span class=\"w3-xlarge\">Input your URL here: </span>\n            <div>\n                <input class=\"w3-xlarge\" type='text' placeholder='https://www.google.com' id='url-target'\n                    onkeydown='if(event.key===\"Enter\") go()' />\n                <button onclick='go()' class=\"w3-xlarge\">Go!</button>\n            </div>\n            <br>\n            <br>\n            </p>\n            <p class=\"w3-medium\">View GitHub source <a class=\"w3-medium\" href=\"https://github.com/binary-person/womginx\" target=\"_blank\">here</a></p>\n        </div>\n    </div>\n</body>\n\n</html>"
  },
  {
    "path": "public/wombat-handler.js",
    "content": "(function () {\n    // rewrite url /main/https:/google.com /main/https://google.com without refreshing the page\n    var rewriteDoubleSlash = window.location.pathname.match(/\\/main(?<mod>\\/[^\\/_]+_)?(?<url_preslash>\\/(?:http|ws)s?:\\/)(?<url_postslash>[^\\/].*)/);\n    if (rewriteDoubleSlash) {\n        window.history.pushState(null, null, '/main' + (rewriteDoubleSlash.groups.mod || '') + rewriteDoubleSlash.groups.url_preslash + '/' + rewriteDoubleSlash.groups.url_postslash + window.location.hash);\n    }\n    var mergeDoubleSlash = function (url) {\n        // only merge if server forcefully merges and url is not a blob or data\n        if (!rewriteDoubleSlash || !/^((http|ws)s?:\\/)/.test(url.toString())) {\n            return url;\n        }\n        // don't merge the real protocol of the url\n        return url.toString().slice(0, 7) + url.toString().slice(7).replace(/\\/+/g, '/');\n    };\n\n    var proxy_dest_split = window.location.pathname.split(/(?=\\/)/);\n    var proxy_prefix = window.location.protocol + \"//\" + window.location.host;\n    var proxy_path = proxy_dest_split.shift() + \"/\";\n    var dest_fullurl = proxy_dest_split.join(\"\").slice(1);\n    var dest_schemeMatch = dest_fullurl.match(/^[^:]*/);\n    var dest_scheme = dest_schemeMatch ? dest_schemeMatch[0] : \"\";\n    var dest_hostMatch = dest_fullurl.match(/^[^:]*:\\/\\/([^/]*)/);\n    var dest_host = dest_hostMatch ? dest_hostMatch[1] : \"\";\n    var processed_flag_attribute = document.currentScript.getAttribute(\"processed-attribute\");\n\n    var absoluteMatch = /^(\\/|https?:\\/\\/|data:image\\/png;)/;\n\n    var wbinfo = {}\n    wbinfo.url = dest_fullurl;\n    wbinfo.timestamp = \"\"; // time\n    wbinfo.request_ts = \"\"; // time\n    wbinfo.prefix = proxy_prefix + proxy_path;\n    wbinfo.mod = \"\";\n    wbinfo.top_url = proxy_prefix + proxy_path + dest_fullurl;\n    wbinfo.is_framed = false;\n    wbinfo.is_live = true;\n    wbinfo.coll = \"\";\n    wbinfo.proxy_magic = \"\";\n    wbinfo.static_prefix = proxy_prefix + \"/wombat/dist/\";\n    wbinfo.wombat_ts = \"\"; // time\n    wbinfo.wombat_scheme = dest_scheme;\n    wbinfo.wombat_host = dest_host;\n    wbinfo.wombat_sec = \"1\"; // time\n\n    wbinfo.wombat_opts = {};\n\n    if (window && window._WBWombat && !window._wb_js_inited && !window._wb_wombat) {\n        // fix google search replaceState\n        window.history._womginx_replaceState = window.history.replaceState;\n        window.history.replaceState = function (stateObj, title, url) {\n            if (window.location.pathname.startsWith(\"/main/https://www.google.com\")) {\n                url = \"\";\n            }\n            return this._womginx_replaceState(stateObj, title, url);\n        };\n\n        // auto-merge slashes if server merges them with redirects (which break non-GET requests such as POST)\n        window.XMLHttpRequest.prototype._womginx_open = window.XMLHttpRequest.prototype.open;\n        window.XMLHttpRequest.prototype.open = function (method, url, async, username, password) {\n            return this._womginx_open(method, mergeDoubleSlash(url), async, username, password);\n        };\n        window.XMLHttpRequest.prototype.url\n        window._womginx_fetch = window.fetch;\n        window.fetch = function (input, init) {\n            if (typeof input === 'string') {\n                return window._womginx_fetch(mergeDoubleSlash(input), init);\n            }\n            var request = new Request(input, init);\n            return _womginx_fetch(mergeDoubleSlash(input.url), request);\n        };\n\n        // add websocket origin support and auto-merge slashes\n        window._womginx_WebSocket = window.WebSocket;\n        window.WebSocket = function (url, protocols) {\n            url = url + '?womginx_ws_origin_header=' + dest_scheme + '://' + dest_host;\n            return new window._womginx_WebSocket(mergeDoubleSlash(url), protocols);\n        };\n\n        // disable Date.now as it breaks hashing functionality in sites like discord\n        _WBWombat.prototype.initDateOverride = function () { };\n\n        // disable making Math.random predictable or \"replayable\"\n        _WBWombat.prototype.initSeededRandom = function () { };\n\n        // disable storage override as it breaks some sites like discord\n        _WBWombat.prototype.initStorageOverride = function () { };\n        // wrap localStorage.get/setItem to mimick behavior of items only accessible per host\n        // get local reference to localStorage in case sites like discord.com intentionally sets it to undefined\n        var localStorage = window.localStorage;\n        var localStorageSetItem = localStorage.setItem;\n        var hostLocalStorage = {};\n        try {\n            if (localStorage.getItem(dest_host)) {\n                hostLocalStorage = JSON.parse(localStorage.getItem(dest_host));\n                if (typeof hostLocalStorage !== 'object') hostLocalStorage = {};\n            }\n        } catch (e) { }\n        // set a timeout to save to localStorage in case scripts in a webpage makes 100 calls to setItem\n        var timeoutLocalStorage = -1;\n        var saveLocalStorage = function () {\n            if (timeoutLocalStorage === -1) {\n                timeoutLocalStorage = setTimeout(function () {\n                    timeoutLocalStorage = -1;\n                    localStorageSetItem.call(localStorage, dest_host, JSON.stringify(hostLocalStorage));\n                }, 50);\n            }\n        };\n        localStorage.key = function (number) {\n            return Object.keys(hostLocalStorage)[number];\n        };\n        localStorage.getItem = function (key) {\n            if (hostLocalStorage[key] === undefined) return null;\n            return hostLocalStorage[key];\n        };\n        localStorage.setItem = function (key, value) {\n            hostLocalStorage[key] = value;\n            saveLocalStorage();\n        };\n        localStorage.removeItem = function (key) {\n            delete hostLocalStorage[key];\n            saveLocalStorage();\n        };\n        localStorage.clear = function () {\n            hostLocalStorage = {};\n            saveLocalStorage();\n        };\n\n        window._wb_wombat = new _WBWombat(window, wbinfo);\n        window._wb_wombat.wombatInit();\n\n        // fix wombat errors in cases of new Blob([]) without options argument\n        window._womginx_Blob = window.Blob;\n        window.Blob = function (data, options = {}) {\n            return new window._womginx_Blob(data, options);\n        };\n        // fix rewriteWorker on instances of \"TrustedScriptURL\"\n        // and also rewrite them and fetch the code using synchronous xhr to rewrite them using client js\n        window._wb_wombat._womginx_rewriteWorker = window._wb_wombat.rewriteWorker;\n        window._wb_wombat.rewriteWorker = function (workerUrl) {\n            // convert rewriteWorker to string in cases of \"TrustedScriptURL\"\n            workerUrl = workerUrl.toString();\n            // snippet of code taken directly from\n            // https://github.com/webrecorder/wombat/blob/61be8e9b67f21d6a0459633a2737cd72c6236a6b/src/wombat.js#L2508\n            if (!workerUrl) return workerUrl;\n            var isBlob = workerUrl.indexOf(\"blob:\") === 0;\n            var isJS = workerUrl.indexOf(\"javascript:\") === 0;\n            if (!isBlob && !isJS) {\n                // fetch worker js synchronously and then replace workerUrl with blob to force rewriting\n                var request = new XMLHttpRequest();\n                request.open(\"GET\", workerUrl, false);\n                request.send();\n                workerUrl = window.URL.createObjectURL(new Blob([request.responseText], { type: 'application/javascript' }));\n            }\n            return this._womginx_rewriteWorker(workerUrl);\n        };\n\n        // addStyles: if website for some reason has recursive css (ex. in file style.css, \"import style.css\"),\n        // ignore already imported css to prevent client from crashing\n        var addedStyles = [];\n        var addStyleContent = function (cssText, relativePath, removeElem, async) {\n            var style = document.createElement(\"style\");\n            if (relativePath) {\n                var replacer = function (match, n1, n2, n3, offset, string) {\n                    var rewrittenN2 = n2;\n                    // check absolute path and append relativePath if necessary\n                    if (absoluteMatch.test(n2)) {\n                        rewrittenN2 = window._wb_wombat.rewriteUrl(n2);\n                    } else {\n                        rewrittenN2 = relativePath + n2\n                    }\n                    // @import url(https://something.com/other.css)\n                    if (n1.startsWith(\"url\") && string.slice(0, offset).trim().endsWith(\"@import\")) {\n                        addStyle(rewrittenN2, null, async);\n                        return \"''\";\n                    }\n                    if (n1.startsWith(\"@import\")) {\n                        if (n2.trim()) {\n                            // recursive add css document\n                            addStyle(rewrittenN2, null, async);\n                            return \"\";\n                        } else {\n                            // erase leftover from style_regex\n                            return \"\";\n                        }\n                    }\n                    return n1 + rewrittenN2 + n3;\n                };\n                style.textContent = cssText\n                    .replace(window._wb_wombat.STYLE_REGEX, replacer)\n                    .replace(window._wb_wombat.IMPORT_REGEX, replacer);;\n            } else {\n                style.textContent = cssText;\n            }\n            if (removeElem) {\n                if (removeElem.tagName === \"STYLE\") {\n                    removeElem.textContent = style.textContent;\n                } else {\n                    if (removeElem.parentNode) {\n                        removeElem.parentNode.insertBefore(style, removeElem);\n                    }\n                    removeElem.remove();\n                }\n            } else {\n                document.head.appendChild(style);\n            }\n        };\n        var addStyle = function (linkToStyle, oldLinkElem, async = true) {\n            if (addedStyles.includes(linkToStyle)) return;\n            var request = new XMLHttpRequest(); // assume xmlhttprequest is already wrapped\n            request.onload = function () {\n                if (request.status < 400) {\n                    addedStyles.push(linkToStyle);\n                    var relativeMatch = /^[^]*\\//;\n                    var relativePath = linkToStyle.match(relativeMatch);\n                    relativePath = relativePath ? relativePath[0] : \"\";\n                    addStyleContent(request.responseText, relativePath, oldLinkElem);\n                }\n            };\n            request.open(\"GET\", linkToStyle, async);\n            request.send();\n        };\n        window._wb_wombat._womginx_rewriteElem = window._wb_wombat.rewriteElem;\n        window._wb_wombat.rewriteElem = function (elem) {\n            // convert link spreadsheet into inline style tags for\n            // js to handle the heavy lifting of regexing everything\n            if (elem && elem.tagName === \"LINK\" && elem.rel === \"stylesheet\"\n                && elem.getAttribute(\"href\").indexOf(\"data:text/css\") !== 0) {\n                // addStyle(elem.getAttribute(\"href\"), elem);\n                // return true;\n            } else if (elem.tagName === \"STYLE\") {\n                // addStyleContent(elem.textContent, \"\", elem);\n                // return true;\n            }\n            return this._womginx_rewriteElem(elem);\n        };\n\n        window.addEventListener(\"DOMContentLoaded\", function () {\n            var elements = Array.from(document.getElementsByTagName(\"*\"));\n            for (var i = 0; i < elements.length; i++) {\n                // rewrite img tags regardless, since nginx replaces it with src to handle\n                // script tags but not srcset of the img tags\n                if (elements[i].tagName !== \"IMG\" && elements[i].hasAttribute(processed_flag_attribute)) {\n                    continue;\n                }\n                if (elements[i].tagName === \"SCRIPT\" && absoluteMatch.test(elements[i].src)) {\n                    var script = elements[i].cloneNode();\n                    elements[i].parentNode.insertBefore(script, elements[i]);\n                } else {\n                    window._wb_wombat.rewriteElem(elements[i]);\n                }\n            }\n        });\n\n        var getProxyUrl = function () {\n            return window.location.href.match(/^https?:\\/\\/[^\\/]+\\/main(\\/[^_\\/]+_)?\\/(.*)/)[2];\n            // return window.location.href;\n        };\n        // unfortunately, I was not able to find another way of copying the window.location\n        // without it throwing illegal invocation or losing setter functionality like window.currentLocation.href = \"something\"\n        var previousLocation = window.location.href;\n        var locationObj = new URL(getProxyUrl());\n        var updateLocationObj = function () {\n            if (window.location.href !== previousLocation) {\n                locationObj = new URL(getProxyUrl());\n            }\n        };\n        var currentLocationProp = {\n            get ancestorOrigins() {\n                updateLocationObj();\n                return window.location.ancestorOrigins;\n            },\n            get href() {\n                updateLocationObj();\n                return locationObj.href;\n            },\n            set href(value) {\n                window.location.href = window._wb_wombat.rewriteUrl(value);\n            },\n            get protocol() {\n                updateLocationObj();\n                return locationObj.protocol;\n            },\n            set protocol(value) {\n                window.location.protocol = value;\n            },\n            get host() {\n                updateLocationObj();\n                return locationObj.host;\n            },\n            set host(value) {\n                window.location.host = value;\n            },\n            get hostname() {\n                updateLocationObj();\n                return locationObj.hostname;\n            },\n            set hostname(value) {\n                window.location.hostname = value;\n            },\n            get port() {\n                updateLocationObj();\n                return locationObj.port;\n            },\n            set port(value) {\n                window.location.port = value;\n            },\n            get pathname() {\n                updateLocationObj();\n                return locationObj.pathname;\n            },\n            set pathname(value) {\n                window.location.pathname = value;\n            },\n            get search() {\n                updateLocationObj();\n                return locationObj.search;\n            },\n            set search(value) {\n                window.location.search = value;\n            },\n            get hash() {\n                updateLocationObj();\n                return locationObj.hash;\n            },\n            set hash(value) {\n                window.location.hash = value;\n            },\n            get origin() {\n                updateLocationObj();\n                return locationObj.origin;\n            },\n            assign(url) {\n                window.location.assign(window._wb_wombat.rewriteUrl(url));\n            },\n            reload() {\n                window.location.reload();\n            },\n            replace(url) {\n                window.location.replace(window._wb_wombat.rewriteUrl(url));\n            },\n            toString() {\n                updateLocationObj();\n                return locationObj.href;\n            }\n        };\n        Object.defineProperty(window, \"currentLocation\", {\n            get: function () {\n                return currentLocationProp;\n            },\n            set: function (value) {\n                window.location = window._wb_wombat.rewriteUrl(value);\n            },\n        });\n    }\n})();"
  },
  {
    "path": "replit-run.sh",
    "content": "#!/bin/bash\n\nset -e\n\nDIR=$(pwd)\nESCAPED_DIR=$(echo $DIR | sed -e 's/\\//\\\\\\//g')\n\ngit pull\n\n# install and build wombat or just update if the folder already exists\nif [ ! -d $DIR/public/wombat/dist ]; then\n    git submodule update --init --recursive\n    cd $DIR/public/wombat\n    npm install && npm run build-prod\nfi\n\ncd $DIR\n\n# modify replit-nginx.conf without modifying nginx.conf to avoid git pull conflict message\nrm -rf replit-nginx-temp\nmkdir replit-nginx-temp\ncp nginx.conf replit-nginx-temp/\ncd replit-nginx-temp\n../docker-sed.sh\n\n# replace with appropriate public dir path\nsed -i \"s/\\/opt\\/womginx\\/public/$ESCAPED_DIR\\/public/g\" nginx.conf\n\n# add missing mime.types\ncurl https://raw.githubusercontent.com/nginx/nginx/master/conf/mime.types -o mime.types\nsed -i \"s/\\/etc\\/nginx\\/mime.types/$ESCAPED_DIR\\/replit-nginx-temp\\/mime.types/g\" nginx.conf\n\n# for some reason, the 1.1.1.1 and 8.8.8.8 dns doesn't work\nsed -i \"s/1.1.1.1/1.1.1.3/\" nginx.conf\n\n# point cache folders to writable directories\nrm -rf /tmp/womginx-cache\nmkdir /tmp/womginx-cache\nCACHE_DIR=\"\\/tmp\\/womginx-cache\"\nsed -i $\"s/http {/http {\\\nclient_body_temp_path $CACHE_DIR\\/client_body;\\\n      proxy_temp_path $CACHE_DIR\\/proxy;\\\n    fastcgi_temp_path $CACHE_DIR\\/fastcgi;\\\n      uwsgi_temp_path $CACHE_DIR\\/uwsgi;\\\n       scgi_temp_path $CACHE_DIR\\/scgi;\\\n/\" nginx.conf\n\nnginx -c $DIR/replit-nginx-temp/nginx.conf -g 'error_log stderr;'\n"
  },
  {
    "path": "replit.nix",
    "content": "{ pkgs }: {\n    deps = [\n        pkgs.nginx\n        pkgs.nodejs-16_x\n    ];\n}"
  }
]