我想配置 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"]