Apache HTTPD别名/目录根据环境变量有条件配置
我们配置了一个Apache HTTPD服务器,以允许浏览特定的文件目录。我们想基于指定部署系统的环境变量设置该目录位置(DEV,QA,POD)。这是我尝试这样做的尝试:
<If "osenv('APP_ENV') == 'dev'">
LogMessage "The value of APP_ENV is dev"
Define DATA_MOUNT /data/AA_images
</If>
<Else>
LogMessage "The value of APP_ENV is other"
Define DATA_MOUNT /data/DIM_Factory
</Else>
Alias /data ${DATA_MOUNT}
<Directory ${DATA_MOUNT}>
Options Indexes FollowSymlinks MultiViews
IndexOptions FancyIndexing VersionSort FoldersFirst NameWidth=32
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
从日志中,我可以看到“ App_env的值为DEV的值”是正确触发的,但是 second 定义是设置的,而不是第一个。启动服务器时,我将获取DIM_FACTORY目录。这是为什么?似乎定义命令没有作为IF/else块的一部分进行评估。
我应该这样做吗?
We have an Apache httpd server configured to allow browsing of a specific file directory. We'd like to set that directory location based on an environment variable that specifies where the system is deployed (dev, qa, prod). Here is my attempt to do that:
<If "osenv('APP_ENV') == 'dev'">
LogMessage "The value of APP_ENV is dev"
Define DATA_MOUNT /data/AA_images
</If>
<Else>
LogMessage "The value of APP_ENV is other"
Define DATA_MOUNT /data/DIM_Factory
</Else>
Alias /data ${DATA_MOUNT}
<Directory ${DATA_MOUNT}>
Options Indexes FollowSymlinks MultiViews
IndexOptions FancyIndexing VersionSort FoldersFirst NameWidth=32
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
I can see from the logs that "The value of APP_ENV is dev" is correctly triggered, but the second Define is being set, not the first. When I start the server, I'm getting the DIM_Factory directory. Why is that? Seems like the Define commands are not being evaluated as part of the If/Else block.
Is there a different way I should be doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论