首页 > 解决方案 > 使用 apache proxypass 重定向到 /blog (wordpress)

问题描述

我在https://www.hackachieve.com上运行一个 ReactJS 应用程序,其结构如下:

端口 80/443:前端 - ReactJS SPA 端口:8000 - 后端 - django rest framework API

我已经在 /var/www/html 上正确安装了 wordpress,我正在尝试将用户从 /blog 重定向到它。

问题是我的代理通行证不起作用。当用户尝试访问https://www.hackachieve.com/blog时发生的情况是它被重定向回主页 /。我通过检查 devtools 发现了 301 重定向。

/etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>

    ServerName hackachieve.com
    ServerAlias www.hackachieve.com
    ServerAdmin joaopaulofurtado@live.com
    DocumentRoot /var/www/hackachieve-frontend

    ProxyPreserveHost On

    ProxyPass / http://localhost:5000/
    ProxyPassReverse / http://localhost:5000/

RewriteEngine on
RewriteCond %{SERVER_NAME} =hackachieve.com [OR]
RewriteCond %{SERVER_NAME} =www.hackachieve.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>

<VirtualHost *:443>

    ServerName hackachieve.com
    ServerAlias www.hackachieve.com
    ServerAdmin joaopaulofurtado@live.com
    DocumentRoot /var/www/hackachieve-frontend


   ProxyPreserveHost On

   ProxyPass / http://localhost:5000/
   ProxyPassReverse / http://localhost:5000/

    ErrorLog ${APACHE_LOG_DIR}/error-frontend.log
    CustomLog ${APACHE_LOG_DIR}/access-frontend.log combined

    RewriteEngine off
    RewriteCond %{SERVER_NAME} =www.hackachieve.com [OR]
    RewriteCond %{SERVER_NAME} =hackachieve.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

    SSLEngine on
    Include /etc/letsencrypt/options-ssl-apache.conf


SSLCertificateFile /etc/letsencrypt/live/hackachieve.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/hackachieve.com/privkey.pem
</VirtualHost>




<VirtualHost *:8000>

    ServerName hackachieve.com
    ServerAlias www.hackachieve.com
    ServerAdmin joaopaulofurtado@live.com
    DocumentRoot /var/www/hackachieve-backend
    ErrorLog ${APACHE_LOG_DIR}/error-backend.log
    CustomLog ${APACHE_LOG_DIR}/access-backend.log combined


 Alias /static /var/www/hackachieve-backend/static
    <Directory /var/www/hackachieve-backend/static>
        Require all granted
    </Directory>

    <Directory /var/www/hackachieve-backend/hackachieve>
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>

WSGIPassAuthorization On
    WSGIDaemonProcess hackachieve python-home=/var/www/hackachieve-backend/venv python-path=/var/www/hackachieve-backend
    WSGIProcessGroup hackachieve
    WSGIScriptAlias / /var/www/hackachieve-backend/hackachieve/wsgi.py

SSLEngine on
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/hackachieve.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/hackachieve.com/privkey.pem



</VirtualHost>

我希望当用户访问https://www.hackachieve.com/blog时,他会被重定向到我的 Wordpress 博客。

我不想让 ReactJS 处理这条路线

标签: wordpressreactjsapachereverse-proxyproxypass

解决方案


推荐阅读