Skip to content

Instantly share code, notes, and snippets.

@perguth
Last active January 28, 2024 19:01
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save perguth/db00315d4ec7616ffd75a355e4abddfb to your computer and use it in GitHub Desktop.
Save perguth/db00315d4ec7616ffd75a355e4abddfb to your computer and use it in GitHub Desktop.
Apache reverse proxy `.htaccess` file eg. for NodeJS. @Uberspace
SetEnvIf Request_URI "^(.*)" PORT=65300
RewriteEngine On
RewriteBase /
# CORS
Header add Access-Control-Allow-Origin "*"
# HTTPS
RewriteCond %{HTTPS} !=on
RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# PORT
RewriteCond %{SERVER_PORT} !^%{ENV:PORT}$
RewriteRule ^(.*) https://%{HTTP_HOST}:%{ENV:PORT}%{REQUEST_URI} [L,R=301]
# RPROXY
# RewriteRule ^(.*) http://localhost:${ENV:PORT}/$1 [P]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment