angularjs - Apache 反向代理不向客户端呈现 Angular 构建的 javascript
问题描述
我正在尝试为我的 2 个站点实现反向代理,但其中一个站点未呈现 html 。
下面是我的 apache ssl config 配置文件
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
ServerName xxxx.xxxx.org
DocumentRoot /var/www/html
ProxyPreserveHost off
SSLProxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass https://localhost:3000/
ProxyPassReverse https://localhost:3000/
</Location>
<Location /app1>
ProxyPass http://localhost:4200/
ProxyPassReverse http://localhost:4200/
</Location>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# A self-signed (snakeoil) certificate can be created by installing
# the ssl-cert package. See
# /usr/share/doc/apache2/README.Debian.gz for more info.
# If both key and certificate are stored in the same file, only the
# SSLCertificateFile directive is needed.
SSLCertificateFile /etc/apache2/sites-available/ssl-certificate/xxxxxccc.crt
SSLCertificateKeyFile /etc/apache2/sites-available/ssl-certificate/xxxx.xxxx.org.key
SSLCertificateChainFile /etc/apache2/sites-available/ssl-certificate/sf_bundle-g2-g1.crt
现在我正在尝试访问我的服务器,https://xxx.fghjk.org/app1
但它显示空白页。我观察到此页面无法加载由 Angular 应用程序构建的 java 脚本文件。
有任何建议
解决方案
您面临的问题很可能是由于 Angular 用于从index.html
. 因此,在像您这样的设置中,有必要将<base>
标签设置为index.html
.
在你的情况下,它需要是<base href="/app1">
.
请参阅https://angular.io/guide/deployment了解更多详细信息或如何正确设置基本 URL 的替代方法。
推荐阅读
- c# - 无法加载文件或程序集 Microsoft.Extensions.ObjectPool
- node.js - 返回大型 JSON 对象时 res.send() 太慢
- javascript - AngularJs 将 ng-model-options 设置为默认值
- c - 在 Linux 内核中读取文件
- ssas - SSAS MDX 总结日期层次结构中的成员资格?
- codeigniter - 使用 Gmail 发送电子邮件不起作用 | 代码点火器
- ms-access - 访问:基于结束日期的下拉列表
- javascript - 将对象值数组从 int 转换为 string
- odata - 如何使用 $expand on ownerid 通过 Dynamics 365 Web API 获取 SystemUser 属性?
- php - 使用 jQuery 获取 th 的 id