作为示例解决方案,请考虑角色nginx-reverse-proxy:
nginx-反向代理/默认值/ main.yml:
default_nginx:
application_context: /{{ application_name }}-{{ application_component_name }}
reverse_proxy:
port: 8080
Run Code Online (Sandbox Code Playgroud)
nginx-reverse-proxy / templates / reverse-proxy.conf:
{% set combined_nginx = default_nginx | combine(nginx, recursive=true) -%}
location {{ combined_nginx.application_context }} {
proxy_pass http://localhost:{{ combined_nginx.reverse_proxy.port }};
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Run Code Online (Sandbox Code Playgroud)
my-nginx-反向代理-meta / main.yml:
dependencies:
- selfcertification-service
- role: nginx-reverse-proxy
nginx: { reverse_proxy: { port: 8095 } }
Run Code Online (Sandbox Code Playgroud)