我已经设置了mkdocs并在端口8000上运行,Nginx被设置为具有以下配置的反向代理。但是,当通过反向代理浏览器访问网站时,请保持"连接..."很长一段时间约2分钟和页面加载。如果我停止" X"使用浏览器,整个页面立即显示。有人可以帮忙吗?
server {
listen 80;
server_name docs.example.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:8000/;
proxy_redirect off;
proxy_buffering off;
}
}
nginx.conf是
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
}
答案 0 :(得分:1)
MkDocs是 静态 网站生成器。
预期的用例是你" build"您的网页为static web pages,然后将已构建的HTML网页上传到您的服务器,服务器将这些网页提供给您的用户。一个主要优点是,由于服务器不需要为每个请求重新处理Markdown和模板,因此速度要快得多。
虽然MkDoc确实包含serve
命令,但所包含的"服务器"仅用于开发。换句话说,在编写文档时,您可以使用开发服务器在本地计算机上查看更改。但是,服务器无意向其他机器或外部世界提供任何服务。从未预料到服务器会有多个同时连接。
因此,不应在端口上列出nginx,而应将其指向静态文件目录,并将MkDocs文档的构建复制到该目录。