Skip to content

Instantly share code, notes, and snippets.

@hiepvq
Forked from perguth/.htaccess
Created October 29, 2023 07:58
Show Gist options
  • Save hiepvq/37c1173ef3f0882458b1178feb94c268 to your computer and use it in GitHub Desktop.
Save hiepvq/37c1173ef3f0882458b1178feb94c268 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