xuwei_qiaofeng 2022-11-05 17:18 采纳率: 100%
浏览 61
已结题

nginxproxymanager 容器反向代理问题

问题遇到的现象和发生背景

使用docker compose 部署nginx-proxy-manager 和jenkins和mysql以及 使用包安装了cockpit。

CONTAINER ID   IMAGE                             COMMAND                  CREATED       STATUS              PORTS                                                                                                             NAMES
e971dabebea0   phpmyadmin:latest                 "/docker-entrypoint.…"   3 hours ago   Up 3 hours          0.0.0.0:9090->80/tcp, :::9090->80/tcp                                                                             phpmyadmin
5c887296b8ab   mysql:5.7                         "docker-entrypoint.s…"   4 hours ago   Up 4 hours          3306/tcp, 33060/tcp                                                                                               runtime-mysql
4bd56190276f   runtime-java17                    "bash -c 'cat /opt/c…"   4 hours ago   Up 4 hours                                                                                                                            java17
661912f09e1c   jc21/nginx-proxy-manager:latest   "/init"                  4 hours ago   Up About a minute   0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:9001->81/tcp, :::9001->81/tcp   nginx-proxy-manager
用代码块功能插入代码,请勿粘贴截图
# ------------------------------------------------------------
# This configuaration only for NginxProxyManager
# You should change your server_name
# ------------------------------------------------------------
  
server {
  set $forward_scheme http;
  set $server         "java17";
  set $port           8080;

  listen 80;
  listen [::]:80;

  server_name example.domain.com;

  access_log /data/logs/proxy-host-9_access.log proxy;
  error_log /data/logs/proxy-host-9_error.log warn;

  location /panel {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_set_header X-Forwarded-For    $remote_addr;
    proxy_set_header X-Real-IP        $remote_addr;
    proxy_pass       http://172.17.0.1:9099;
    # Required for web sockets to function
    proxy_http_version 1.1;
    proxy_buffering off;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    # Pass ETag header from Cockpit to clients.
    # See: https://github.com/cockpit-project/cockpit/issues/5239
    gzip off;
  }

  location /phpmyadmin {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_set_header X-Forwarded-For    $remote_addr;
    proxy_set_header X-Real-IP        $remote_addr;
    proxy_pass       http://phpmyadmin:80;
    rewrite ^/phpmyadmin(/.*)$ $1 break;
  }

  location /nginxproxymanager {
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Scheme $scheme;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_set_header X-Forwarded-For    $remote_addr;
    proxy_set_header X-Real-IP        $remote_addr;
    proxy_pass       http://nginx-proxy-manager:81;
    rewrite  ^/nginxproxymanager/?(.*)$ /$1 break;
    proxy_http_version 1.1;
    proxy_redirect off;
    proxy_set_header Upgrade $http_upgrade;
    proxy_cache_bypass $http_upgrade;
    proxy_set_header Connection $http_connection;
    proxy_cache_bypass $http_secret_header;
    proxy_set_header Accept-Encoding "";
    add_header Pragma "no-cache";
    add_header Cache-Control "no-cache";
    # source changes
    sub_filter 'href="/' 'href="/nginxproxymanager/';
    sub_filter 'src="/' 'src="/nginxproxymanager/';
    sub_filter '/api' '/nginxproxymanager/api';
    sub_filter '/assets' '/nginxproxymanager/assets';
    sub_filter '/js/' '/nginxproxymanager/js/';
    # script changes
    sub_filter 'r.p="/' 'r.p="/nginxproxymanager/';
    sub_filter '"/login' '"/nginxproxymanager/login';
    sub_filter 'case"/logout"' 'case"/nginxproxymanager/logout"';
    sub_filter 'window.location="/"' 'window.location="/nginxproxymanager/"';
    sub_filter 'history.start({pushState:!0})' 'history.start({pushState:!0,root: "/nginxproxymanager/"})';
    sub_filter 'i.history.navigate(e.' 'i.history.navigate(e.replace("/nginxproxymanager","").';
    sub_filter_types text/css text/javascript application/javascript;
    sub_filter_once off;
  }

  location / {
    # Proxy!
    include conf.d/include/proxy.conf;
  }
  
  # Custom
  include /data/nginx/custom/server_proxy[.]conf;
}
运行结果及报错内容

jenkins反向代理和cockpit不能同时生效。

我想要达到的结果

期望 IP/panel 指向cockpit
期望 IP/nginxproxymanager 指向nginx管理后台
期望 IP/jenkins 指向 jenkins

  • 写回答

2条回答

      报告相同问题?

      相关推荐 更多相似问题

      问题事件

      • 系统已结题 11月14日
      • 已采纳回答 11月6日
      • 创建了问题 11月5日

      悬赏问题

      • ¥20 如何从 .html url 启动/激活 .py 文件(sql debug)
      • ¥15 c#调用soap出错,soapui中可以
      • ¥100 CBIS-DDSM kaggle 资料处理
      • ¥30 python 在 excel 用 OpenPyXL 怎么实现以下代码
      • ¥15 pywinauto 无法捕获到元素
      • ¥15 ARfoundation (可能由于没打开摄像头的)黑屏问题
      • ¥15 C++类模板继承模板本身,有偿
      • ¥15 pycharm打包项目包含mp3文件,运行exe程序后mp3文件没有执行。
      • ¥15 Quantlib求discount factors
      • ¥15 JS宏提取满足比率的字符区段