![根据 HTTP 标头提供不同语言的网页,使用 Apache 协商模块 - 仅显示目录列表](https://linux22.com/image/787460/%E6%A0%B9%E6%8D%AE%20HTTP%20%E6%A0%87%E5%A4%B4%E6%8F%90%E4%BE%9B%E4%B8%8D%E5%90%8C%E8%AF%AD%E8%A8%80%E7%9A%84%E7%BD%91%E9%A1%B5%EF%BC%8C%E4%BD%BF%E7%94%A8%20Apache%20%E5%8D%8F%E5%95%86%E6%A8%A1%E5%9D%97%20-%20%E4%BB%85%E6%98%BE%E7%A4%BA%E7%9B%AE%E5%BD%95%E5%88%97%E8%A1%A8.png)
我想配置 Apache,这样当我们发送带有给定语言标头的请求时,服务器应该向我们发送正确的版本。例如,我有index.eng.html
和index.de.html
。根据 HTTP 标头,服务器应该向我发送正确的版本。我想在 Docker 容器内制作它。
现在我唯一看到的就是目录列表...出了什么问题?
# Use the official Apache base image
FROM httpd:latest
# Install required Apache modules
RUN apt-get update && apt-get install -y apache2
# Enable necessary Apache modules
RUN a2enmod negotiation
# Copy the content files to the appropriate directory
COPY index.eng.html index.de.html index.pl.html /usr/local/apache2/htdocs/
# Append the configuration directly to the Apache configuration file
RUN echo "LoadModule negotiation_module modules/mod_negotiation.so" >> /usr/local/apache2/conf/httpd.conf
RUN echo "LanguagePriority en pl de" >> /usr/local/apache2/conf/httpd.conf
RUN echo "ForceLanguagePriority Prefer Fallback" >> /usr/local/apache2/conf/httpd.conf
EXPOSE 80
# Remove the default index.html file
RUN rm /usr/local/apache2/htdocs/index.html
# Start Apache in the foreground
CMD ["httpd", "-D", "FOREGROUND"]