我在 Apache 中的反向代理设置如下:
具有地址的服务器 Awww.proxyserver.com/graphql
是反向代理服务器。 (magento-php)
它映射到:具有地址的服务器 B example.com
(reactjs)
这种类型在调试模式(npm run start
)下运行时可以正常工作。
例如:当服务器调用请求时/graphql?query1=query1&query2=query2
,它会重定向到https://proxyserver.com/graphql?query1=query1&query2=query2
但在apache中,它不起作用。它调用http://example.com/graphql?query1=query1&query2=query2
我该如何解决?
我的反向代理在服务器 B 上配置如下(www.example.com):
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/example.com/build
ServerName example.com
ServerAlias www.example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPreserveHost On
ProxyPass "/graphql" "https://proxyserver.com/graphql"
ProxyPassReverse "/graphql" "https://proxyserver.com/graphql"
</VirtualHost>
这是服务器A的配置
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin [email protected]
DocumentRoot /etc/pub
ServerName proxyserver.com
ErrorLog logs/cezanno-error_log
LimitRequestBody 104857600
<Proxy "unix:/var/opt/remi/php73/run/php-fpm/php73-fpm.sock|fcgi://proxyserver.com">
ProxySet timeout=100
</Proxy>
<FilesMatch \.(php|phar)$>
SetHandler "proxy:fcgi://proxyserver.com"
</FilesMatch>
SSLCertificateFile /path/to/cert/directory/cert.pem
SSLCertificateKeyFile /path/to/cert/directory/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateChainFile /path/to/cert/directory/chain.pem
</VirtualHost>
</IfModule>