Url 单侧路径操纵
在谷歌云平台中,我们确实有一个haproxy,作为我们内部VPN的代理,并将URL从GCP DNS重定向到proxy.mycompany.com(我们的haproxy),在那里我们进行进一步的操作Url 单侧路径操纵,url,proxy,haproxy,forward,Url,Proxy,Haproxy,Forward,在谷歌云平台中,我们确实有一个haproxy,作为我们内部VPN的代理,并将URL从GCP DNS重定向到proxy.mycompany.com(我们的haproxy),在那里我们进行进一步的操作 Haproxy来自图像2.0.8-alpine Nginx基于图像1-alpine 最近我安装了nginx,它提供静态文件 Nginx是为上的自动索引而设置的,可在url静态文件.mycompany.com上访问,并配置为显示gcs存储桶的根目录。因此,如果您访问静态文件.mycompany.com,
Haproxy
来自图像2.0.8-alpine
Nginx
基于图像1-alpine
最近我安装了nginx,它提供静态文件
Nginx是为上的自动索引而设置的,可在url静态文件.mycompany.com
上访问,并配置为显示gcs存储桶的根目录。因此,如果您访问静态文件.mycompany.com
,您将看到gcs bucket的内容:
- 目录
静态文件
- 桶中的任何文件
静态文件
目录包含由生成的静态网站文件。
这些文件包含的路径类似于/docu/file.md
我已成功配置haproxy,使其能够将urlwebsite.mycompany.com
的任何请求转发到静态文件.mycompany.com/static文件
,并通过在haproxy配置的后端部分
中配置,显示生成的静态网站:
acl p_root path -i /
http-request set-path /static-files/\1 if p_root
每次我访问website.mycompany.com
时,路径都会重定向到website.mycompany.com/static files
(实际上是static files.mycompany.com/static files
)
然而,该网站被破坏了:
- css未加载,文件位于/中,请求的目标是
,但由于上面的路径操作,可以在website.mycompany.com/mycss.file
下找到该文件website.mycompany.com/static files/mycss.file
- 网站上的每个链接都死掉了,请求
,但文件仍在保存中website.mycompany.com/my-link-to-file
website.mycompany.com/static files/my link to file
global
log stdout format raw local0 info
maxconn 30000
tune.ssl.default-dh-param 2048
resolvers vpc
parse-resolv-conf
hold valid 120s
defaults
mode http
log global
option dontlognull
#option tcplog
option httplog
option forwardfor
option redispatch
maxconn 3000
retries 3
timeout connect 5s
timeout client 50s
timeout server 50s
timeout tunnel 1h
timeout client-fin 30s
timeout http-keep-alive 4s
balance roundrobin
default-server check resolvers vpc
default-server on-marked-down shutdown-sessions
default-server max-reuse 100
frontend http
bind *:80
redirect scheme https code 302 if !{ ssl_fc }
monitor-uri /_healtz
use_backend %[hdr(host),lower]
frontend https
bind *:443 ssl no-sslv3 crt /config/haproxy_certificate.pem alpn http/1.1,h2
http-response add-header Via 1.1\ %[env(HOSTNAME)]
http-request add-header Via 1.1\ %[env(HOSTNAME)]
http-request add-header X-Forwarded-Proto https
http-request capture req.hdr(Host) len 40
http-request capture req.hdr(User-Agent) len 120
use_backend %[hdr(host),lower]
backend proxy.mycompany.com
stats enable
stats uri /
我希望实现以下目标:
通过访问website.mycompany.com
我将被转发到后台的静态文件.mycompany.com/static文件
,但是URL将保持为website.mycompany.com
,因此生成的静态网站路径保持工作,静态网站也保持工作。还是我错了
我愿意接受任何合理的建议
谢谢嗯,最后还是很简单的
http-request replace-uri ([^/:]*://[^/]*)?(.*) \1/static-files\2
成功了
编辑:
避免/静态文件/静态文件/
acl remove_static-files path_beg -i /architecture-diagrams
http-request replace-uri ([^/:]*://[^/]*)?(.*) \1/static-files\2 if !remove_static-files