【发布时间】:2019-12-19 16:47:05
【问题描述】:
我正在将反向代理从 NGINX 迁移到 Apache,但不知道如何将 nginx 重写转换为 Apache mod 重写。
这是我的 nginx 配置的相关部分:
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;
}
}
这是我目前对 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
很遗憾,我的重写规则似乎被打破了?
AH00526: Syntax error on line 253 of C:/xampp/apache/conf/httpd.conf:
RewriteRule: bad flag delimiters
希望有任何提示。
【问题讨论】:
-
首先,从
RewriteRule行中删除rewrite字 -
也许这个工具可以帮助你labs.gidix.de/nginx
-
欣赏nginx转换器,但效果不是很好。 :)
标签: apache nginx mod-rewrite