I'm migrating a reverse proxy from NGINX to Apache, but can't wrap my head around how to convert the nginx rewrites to Apache mod rewrite.
Here's the relevant part of my nginx configuration:
server {
listen 443 ssl;
server_name localhost;
#### REWRITE FOR APP PROXY ###
rewrite ^/app-proxy/([^/]+?)/([^/]+?)/(.*)$ /$2/$1/$3 last;
#### Final destination, SAL-ASSETS (STATIC FILES)
location /sal-assets/ {
alias /var/www/sal-assets/;
expires 30d;
}
#### Final destination TOMCAT & NG SERVE
location / {
proxy_pass http://localhost:8080;
}
location /sal-frontnd/ {
proxy_pass http://localhost:4200;
}
location /sal-backend/ {
proxy_pass http://localhost:4200;
}
}
Here's what I've got so far for Apache:
ProxyPass /sal-frontend/ http://localhost:4200/sal-frontend/
ProxyPassReverse /sal-frontend/ http://localhost:4200/sal-frontend/
ProxyPass /sal-admin/ http://localhost:4200/sal-admin/
ProxyPassReverse /sal-admin/ http://localhost:4200/sal-admin/
ProxyPass /sal-backend/ http://localhost:8080/
ProxyPassReverse /sal-backend/ http://localhost:8080/
<Directory "C:/xampp/htdocs">
RewriteEngine on
RewriteRule rewrite ^/app-proxy/([^/]+?)/([^/]+?)/(.*)$ /$2/$1/$3
Unfortunately my rewrite rule seems to be broken?
AH00526: Syntax error on line 253 of C:/xampp/apache/conf/httpd.conf:
RewriteRule: bad flag delimiters
Would appreciate any hint.
The following finally worked for me:
<Directory />
RewriteEngine On
AllowOverride All
Require all denied
RewriteRule /app-proxy/([^/]+?)/([^/]+?)/(.*) /$2/$1/$3 [L,NC]
</Directory>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.