【问题标题】:Create apache httpd forward proxy behind Nginx Ingress在 Nginx Ingress 后面创建 apache httpd 转发代理
【发布时间】:2021-11-29 00:28:53
【问题描述】:

我需要在 k8s (GKE) 集群上创建一个转发代理。 为此,我创建了一个简单的 httpd 部署和一个基本的 Nginx 入口(具有良好配置的服务)。

正向代理配置:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
<VirtualHost *:80>
   HttpProtocolOptions Unsafe
   ErrorLog /var/log/test.log
   LogLevel debug
   CustomLog /var/log/test2.log combined
   ProxyPreserveHost On
   ProxyRequests On
   ProxyVia On
   ProxyStatus On
   ProxyTimeout 60
   AllowCONNECT 1080 443 8443 9443 8000-8900
   <Proxy "*">
      Allow from all
   </Proxy>
</VirtualHost>

Nginx 入口:


apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: stat-proxy
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
    - host: <somehost>
      http:
        paths:
          - path: /
            backend:
              serviceName: stats-service-proxy
              servicePort: 80

从 pod 内部运行命令 curl -L -x http://127.0.0.1:80 -I http://www.google.com 时,它按预期工作并返回状态代码 200

在运行命令 curl -x http://&lt;ingress-nginx-hostname&gt;:80 -I http://www.google.com 时,我从看起来像 Ingress 的地方收到错误 404

<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

【问题讨论】:

    标签: apache nginx proxy nginx-ingress


    【解决方案1】:

    我没有使用Ingress,而是将服务的类型更改为LoadBalancer

    【讨论】:

      猜你喜欢
      • 2019-05-09
      • 2018-03-12
      • 1970-01-01
      • 2013-09-04
      • 2021-11-05
      • 2019-01-29
      • 1970-01-01
      • 2010-12-03
      • 2019-07-21
      相关资源
      最近更新 更多