apache2 for phpMyAdmin在Haproxy后面

发布于 2025-02-01 13:10:45 字数 3229 浏览 3 评论 0原文

我正在寻找解决我的问题,但我仍然无法解决问题...

我在云VM中有一个防火墙(PFSENSE),我在该VM上有一个反向代理(Haproxy),可以在2个后端服务器上平衡和卸载HTTPS。 这2台服务器是经典灯(Ubuntu Apache2 2.4.53,Php 7.4,mysql) 我在另一个端口上使用phpmyadmin(例如1234),并且我在反向代理上使用相同的域(example.com),哪个地址:

  • example.com:1234/phpmyadmin1 = > lamp1
  • 示例.com:1234/phpmyadmin2 => Lamp2

所有这些都很好,但是当我仍在学习时,我犯了几个月后意识到的错误。我可以使用php-fpm而不是PHP-MOD,我想使用PHP8.1和PHP7.4,而我的Ubuntu版本是21.04(是的,我愚蠢地与LTS误解了...) 因此,为了完成所有这些操作,我终于决定在新的VM上启动新的安装:Lamp3

我使用了带有PHPMyAdmin的新LAMP3,我跟随Digitalocean Tuto进行PHP-FPM,并使用简单的网页进行了测试,我可以切换到PHP8。 1或PHP7.4。一切听起来不错。

现在,我想将LAMP3集成在反向代理中,以便将example.com rentirect.com:1234/phpmyadmin3重定向到我的phpmyadmin

时,当我使用VPN时,我可以尝试 http://10.0.0.3:1234/phpmyadmin3 ,它可以工作。 但是当我用

此错误404表示我在服务器上,而不是在反向代理上。所以我被重定向到正确的位置。

我更改了使用原始别名(/phpmyadmin)的配置,并在反向代理上更新。猜猜是什么,它在起作用!而且我确定它是LAMP3,因为我对PhpMyAdmin有php8.1(我不在其他2盏灯上),

我尝试使用的是在VirtualHost中包含默认的phpmyamin,但我更喜欢将全部放在1个位置,所以我做了一个VirtualHost phpmyadmin.conf带有所有信息(请参阅下文) 我在Apache Conf(A2disconf phpMyAdmin)中禁用phpmyadmin 我在这个虚拟霍斯特(Virtualhost)中尝试了很多不同的事情,现在我

再次迷失了,但是当我将别名从 /phpmyadmin3更改为 /phpmyadmin时,一切都应该按照可能的方式工作。

那么,为什么,如何解决呢? 我的别名怎么了?

phpmyadmin.conf

<VirtualHost *:17380>
        ServerName localhost
        Alias /phpmyadmin3 /usr/share/phpmyadmin
        DocumentRoot /usr/share/phpmyadmin
        DirectoryIndex index.php
        <Directory /usr/share/phpmyadmin>
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            allow from all
            Require all granted
        </Directory>
        <Directory /usr/share/phpmyadmin/templates>
            Require all denied
        </Directory>
        <Directory /usr/share/phpmyadmin/libraries>
            Require all denied
        </Directory>
        <FilesMatch \.php$>
           SetHandler "proxy:unix:/run/php/php8.1-fpm.sock|fcgi://localhost"
        </FilesMatch>
        ErrorLog ${APACHE_LOG_DIR}/phpmyadmin.error.log
        CustomLog ${APACHE_LOG_DIR}/phpmyadmin.access.log combined
    </VirtualHost>

VirtualHost *:17380>
    ServerName example.com
    Alias /phpmyadmin3 /usr/share/phpmyadmin
    DocumentRoot /usr/share/phpmyadmin
    DirectoryIndex index.php
    <Directory /usr/share/phpmyadmin>
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        allow from all
        Require all granted
    </Directory>
    <Directory /usr/share/phpmyadmin/templates>
        Require all denied
    </Directory>
    <Directory /usr/share/phpmyadmin/libraries>
        Require all denied
    </Directory>
    <FilesMatch \.php$>
       SetHandler "proxy:unix:/run/php/php8.1-fpm.sock|fcgi://localhost"
    </FilesMatch>
    ErrorLog ${APACHE_LOG_DIR}/phpmyadmin.error.log
    CustomLog ${APACHE_LOG_DIR}/phpmyadmin.access.log combined
</VirtualHost>

版本

Ubuntu 22.04
apache 2.4.53
mysql 5.7.38
php-fpm7.4
php-fpm8.1

I'm looking looking for solving my problem, but still I cannot solve it...

I have a firewall (pfsense) in a cloud VM on which I have a reverse proxy (HAproxy) for balancing and offload https on 2 backend servers.
These 2 servers are classic LAMP (Ubuntu Apache2 2.4.53, PHP 7.4, MySQL)
I 'm using phpmyadmin on a different port (let's say 1234), and I'm using the same domain (example.com) on the reverse proxy which balance to lamp1 or lamp2 depend which address :

  • example.com:1234/phpmyadmin1 => LAMP1
  • example.com:1234/phpmyadmin2 => LAMP2

All of that works nice, but as I'm still learning, I made mistakes that I realized after few months. I could use php-fpm instead php-mod, I would like to use php8.1 and php7.4 and big mistake my Ubuntu version was 21.04 (yes I stupidly mistake with the LTS...)
So for doing all of that, I finally decide to start a fresh install on a new VM : LAMP3

I have my new LAMP3 with phpmyadmin, I followed DigitalOcean tuto for PHP-FPM, tested with simple web page, I can switch to php8.1 or php7.4. Everything sounds good.

Now I would like to integrate the LAMP3 in the reverse proxy in order to redirect example.com:1234/phpmyadmin3 to my phpmyadmin

When I'm on the VPN I can try http://10.0.0.3:1234/phpmyadmin3 and it works.
But when I try from internet with https://example.com:1234/phpmyadmin3 , I have on error 404 Not Found .

This error 404 mean I'm on the server and not on the reverse proxy. so I'm redirected to the right place.

I changed the config for using original alias (/phpmyadmin) and update it on the reverse proxy. Guess what, it's working ! And I'm sure it's LAMP3 because I have php8.1 for phpmyadmin (that I don't on the 2 others LAMP)

I tried with include the default phpmyamin in the virtualhost, but I prefer having all in 1 place so I made a virtualhost phpmyadmin.conf with all info (see below)
I disable phpmyadmin in apache conf (a2disconf phpmyadmin)
I tried a lot of different things into this virtualhost that now I'm getting lost

I reapeat again, but when I change the alias from /phpmyadmin3 to /phpmyadmin everything works as it should.

So why, where how to solve that ?
What's wrong with my alias ?

phpmyadmin.conf

<VirtualHost *:17380>
        ServerName localhost
        Alias /phpmyadmin3 /usr/share/phpmyadmin
        DocumentRoot /usr/share/phpmyadmin
        DirectoryIndex index.php
        <Directory /usr/share/phpmyadmin>
            Options FollowSymLinks
            AllowOverride All
            Order allow,deny
            allow from all
            Require all granted
        </Directory>
        <Directory /usr/share/phpmyadmin/templates>
            Require all denied
        </Directory>
        <Directory /usr/share/phpmyadmin/libraries>
            Require all denied
        </Directory>
        <FilesMatch \.php
gt;
           SetHandler "proxy:unix:/run/php/php8.1-fpm.sock|fcgi://localhost"
        </FilesMatch>
        ErrorLog ${APACHE_LOG_DIR}/phpmyadmin.error.log
        CustomLog ${APACHE_LOG_DIR}/phpmyadmin.access.log combined
    </VirtualHost>

VirtualHost *:17380>
    ServerName example.com
    Alias /phpmyadmin3 /usr/share/phpmyadmin
    DocumentRoot /usr/share/phpmyadmin
    DirectoryIndex index.php
    <Directory /usr/share/phpmyadmin>
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        allow from all
        Require all granted
    </Directory>
    <Directory /usr/share/phpmyadmin/templates>
        Require all denied
    </Directory>
    <Directory /usr/share/phpmyadmin/libraries>
        Require all denied
    </Directory>
    <FilesMatch \.php
gt;
       SetHandler "proxy:unix:/run/php/php8.1-fpm.sock|fcgi://localhost"
    </FilesMatch>
    ErrorLog ${APACHE_LOG_DIR}/phpmyadmin.error.log
    CustomLog ${APACHE_LOG_DIR}/phpmyadmin.access.log combined
</VirtualHost>

Versions

Ubuntu 22.04
apache 2.4.53
mysql 5.7.38
php-fpm7.4
php-fpm8.1

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谢绝鈎搭 2025-02-08 13:10:45

我友好地解决了我的问题...

而不是使用别名 /phpmyadmin3,我尝试了使用别名 /PMA3和 /测试
而且有效!

太...我想这是我的服务器上有缓存的东西吗?
当我从不同的PC中尝试使用不同的浏览器在私有模式下尝试使用不同的PC时,我的浏览器不是。

我猜解决了

I kind if solve my problem...

Instead of using the alias /phpmyadmin3 , I tried with alias /pma3 and /test
And it works !

Soooo... I guess it's something with cache on my server ?
Not with my browser as I tried from different PC with different browser in private mode.

Solve I guess

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文