Metadata-Version: 2.4
Name: apache2nginx
Version: 0.0.1
Summary: A CLI tool to convert .htaccess files into drop-in NGINX config files for cPanel NGINX Standalone
Home-page: https://gerrit.cloudlinux.com/plugins/gitiles/apache2nginx/
Author: Danila Vershinin
Author-email: dvershinin@cloudlinux.com
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development
Classifier: Topic :: Utilities
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: packaging
Requires-Dist: pyparsing==3.0.9
Requires-Dist: requests
Requires-Dist: lxml
Requires-Dist: psutil
Provides-Extra: tests
Requires-Dist: packaging; extra == "tests"
Requires-Dist: pyparsing==3.0.9; extra == "tests"
Requires-Dist: requests; extra == "tests"
Requires-Dist: lxml; extra == "tests"
Requires-Dist: psutil; extra == "tests"
Requires-Dist: pytest>=4.4.0; extra == "tests"
Requires-Dist: pytest-mock; extra == "tests"
Requires-Dist: flake8; extra == "tests"
Requires-Dist: test-utils; extra == "tests"
Requires-Dist: pyyaml; extra == "tests"
Requires-Dist: tqdm; extra == "tests"
Requires-Dist: pytest-xdist; extra == "tests"
Requires-Dist: psutil; extra == "tests"
Requires-Dist: pytest-snapshot~=0.9.0; extra == "tests"
Requires-Dist: pytest-check~=2.5.0; extra == "tests"
Requires-Dist: pluggy~=1.5.0; extra == "tests"
Provides-Extra: docs
Requires-Dist: mkdocs==1.2.1; extra == "docs"
Requires-Dist: mkdocs-material; extra == "docs"
Requires-Dist: mkdocstrings; extra == "docs"
Requires-Dist: markdown-include; extra == "docs"
Provides-Extra: build
Requires-Dist: packaging; extra == "build"
Requires-Dist: pyparsing==3.0.9; extra == "build"
Requires-Dist: requests; extra == "build"
Requires-Dist: lxml; extra == "build"
Requires-Dist: psutil; extra == "build"
Requires-Dist: pytest>=4.4.0; extra == "build"
Requires-Dist: pytest-mock; extra == "build"
Requires-Dist: flake8; extra == "build"
Requires-Dist: test-utils; extra == "build"
Requires-Dist: pyyaml; extra == "build"
Requires-Dist: tqdm; extra == "build"
Requires-Dist: pytest-xdist; extra == "build"
Requires-Dist: psutil; extra == "build"
Requires-Dist: pytest-snapshot~=0.9.0; extra == "build"
Requires-Dist: pytest-check~=2.5.0; extra == "build"
Requires-Dist: pluggy~=1.5.0; extra == "build"
Requires-Dist: mkdocs==1.2.1; extra == "build"
Requires-Dist: mkdocs-material; extra == "build"
Requires-Dist: mkdocstrings; extra == "build"
Requires-Dist: markdown-include; extra == "build"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: summary

## Apache forgiving syntax

```apache
<ifModule mod_headers.c>Header set Testy "no-cache 2
Header set Testy "no-cache 2
</ifmodule>
```

Does not error with 500:

* everything after `>` is ignored; in other words the first `Header` does not apply at all
* Apache "closes" the missing quote, and the header being sent is `no-cache 2`

Next example is:

```apache
<Files ~ âxmlrpc.phpâ>
Order allow,deny
Deny from all
</Files>
```

This is not what is intended (e.g. `xmlrpc.php` isn't forbidden), but it is accepted
by Apache and `âxmlrpc.phpâ` is blocked.

Another example:

```apache
<FilesMatch "\.(html|htm|js|css|php|txt)>
FileETag None
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Testy "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</FilesMatch>
```

This actually works as intended despite missing closing quote.

## Exit codes

* `1` - failed to run `nginx -t` or otherwise invoke NGINX for checking generated configuration
* `2` - unable to read the context file
* `3` - the context file is malformed (invalid JSON)
* `4` - the context file is malformed (missing keys)
* `5` - unsupported `--output` type
* `6` - an external program (NGINX, etc.) is not found on the system

## TODO

* evaluate this for parsing mime.types config: https://github.com/peakwinter/python-nginx/blob/master/tests.py
* https://httpd.apache.org/docs/2.4/mod/mod_alias.html#redirectmatch
* While applying, test with nginx -t first, because charset_types long can't be fixed
* `Header` directive handling
* `RequestHeader` directive handling
* Case-insensitive directives application (Done)
* expr= condition skip generating config for such directive
* We are mix-matching native header module and headers-more just because the latter doesn't support "append"
* We could modify headers-more to be able to append
* Handling multiline `\` via pyparsing native methods, if any (instead of the workaround)

https://api.docs.cpanel.net/openapi/whm/operation/php_get_vhost_versions/
https://docs.cpanel.net/knowledge-base/experimental-software/nginx-standalone/
https://api.docs.cpanel.net/openapi/whm/operation/php_get_vhost_versions/
https://httpd.apache.org/docs/2.4/howto/htaccess.html

## Set up development

```commandline
pip3 install -e ".[tests]"
```
