mkdocs nginx 反向代理速度慢
mkdocs nginx reverse proxy slow
我在端口 8000 上设置了 mkdocs 和 运行,Nginx 被设置为具有以下配置的反向代理。但是,当通过反向代理访问该站点时,浏览器会在 "connecting..." 停留很长时间,大约 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 {
# }
# }
}
MkDocs 是一个静态 网站生成器。
预期用例是您 "build" 您的页面作为 static web pages,然后将已构建的 HTML 页面上传到您的服务器,服务器将这些页面提供给您的用户。一个主要的优点是,由于服务器不需要为每个请求重新处理 Markdown 和模板,因此速度要快得多。
虽然 MkDocs 确实包含 serve
命令,但包含的 "server" 仅用于开发。换句话说,在编写文档时,您可以使用开发服务器在本地机器上实时查看更改。但是,服务器并不打算为其他机器或外部世界提供任何服务。没想到服务器会有多个同时连接。
因此,与其将 nginx 列在端口上,不如将其指向静态文件目录,并将 MkDocs 文档的构建复制到该目录。
我在端口 8000 上设置了 mkdocs 和 运行,Nginx 被设置为具有以下配置的反向代理。但是,当通过反向代理访问该站点时,浏览器会在 "connecting..." 停留很长时间,大约 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 {
# }
# }
}
MkDocs 是一个静态 网站生成器。
预期用例是您 "build" 您的页面作为 static web pages,然后将已构建的 HTML 页面上传到您的服务器,服务器将这些页面提供给您的用户。一个主要的优点是,由于服务器不需要为每个请求重新处理 Markdown 和模板,因此速度要快得多。
虽然 MkDocs 确实包含 serve
命令,但包含的 "server" 仅用于开发。换句话说,在编写文档时,您可以使用开发服务器在本地机器上实时查看更改。但是,服务器并不打算为其他机器或外部世界提供任何服务。没想到服务器会有多个同时连接。
因此,与其将 nginx 列在端口上,不如将其指向静态文件目录,并将 MkDocs 文档的构建复制到该目录。