我试图在运行在podman容器中的nginx服务器上托管我的MkDocs文档。容器和nginx运行正常,我可以访问站点,所有的html文件都在那里,并且是可读的。只是格式不正确(当我尝试使用mkdocs serve时,所有这些都能正常工作)。它只是一个没有任何纯html站点图形/ UI的MkDocs。
这是我在容器上运行的Containerfile / Image
FROM ubuntu:22.04
#Copying MkDocs files
COPY /Kubernetes/site /usr/share/mkdocs-site
#Installing nginx
RUN apt update && \
apt -y install nginx && \
#Switching out the default nginx.conf file for the correct one
RUN rm /etc/nginx/nginx.conf
COPY /nginx/nginx.conf /etc/nginx
EXPOSE 8080
#restarting nginx so the .conf file is reloaded
RUN mkdir /usr/share/nginx-log
RUN touch /usr/share/nginx-log/nginx.log
CMD service nginx restart && tail -F /usr/share/nginx-log/nginx.log(我知道有许多不同的东西可能是dene,但它们不应该影响nginx站点?)
这是我的nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events
{
worker_connections 768;
#multi_accept on;
}
http
{
server
{
location /mkdocs-site/
{
autoindex on;
root /usr/share;
}
}
}(由于服务器运行正常,这也不应该是问题所在)
这是我的mkdocs.yml
site_name: oss-k8s-documentation
site_url: ""
nav:
- Change Management:
- Custom Requirement: Custom_requirement.md
...
- Misc:
- Adding new Clusters to Rancher: adding_new_clusters_to_rancher.md
...
- Images
- Alerting Installation: alerting_installation_1.png
theme: readthedocs(这里没有输入完整的文件,因为我无法复制代码atm)
我还检查了MkDocs构建是否正确运行,并且找不到anny问题。我遵循我可以找到的指南,并试图自己修复它,所以如果有人可以提供任何帮助,为什么网站没有以正确的格式显示,我将非常感激。
发布于 2022-10-25 08:05:19
我能修好它。问题在于我的nginx.conf。要使browser/nginx正确读取theme.css文件,需要在nginx.conf文件的位置块中添加include /etc/nginx/mime.types;
https://stackoverflow.com/questions/74153179
复制相似问题