1> 用oneinstack一键安装nginx
wget -c http://mirrors.linuxeye.com/oneinstack-full.tar.gz && tar xzf oneinstack-full.tar.gz && ./oneinstack/install.sh --nginx_option 1 --pureftpd --reboot
2> 修改配置
a. 配置中添加重定向 return 301 https://$host$request_uri;
~# vim /usr/local/nginx/conf/nginx.conf
user www www;
worker_processes auto;
error_log /data/wwwlogs/error_nginx.log crit;
pid /var/run/nginx.pid;
worker_rlimit_nofile 51200;
events {
use epoll;
worker_connections 51200;
multi_accept on;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 1024m;
client_body_buffer_size 10m;
sendfile on;
tcp_nopush on;
keepalive_timeout 120;
server_tokens off;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
fastcgi_intercept_errors on;
#Gzip Compression
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 6;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
text/javascript application/javascript application/x-javascript
text/x-json application/json application/x-web-app-manifest+json
text/css text/plain text/x-component
font/opentype application/x-font-ttf application/vnd.ms-fontobject
image/x-icon;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
##Brotli Compression
#brotli on;
#brotli_comp_level 6;
#brotli_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;
##If you have a lot of static files to serve through Nginx then caching of the files' metadata (not the actual files' contents) can save some latency.
#open_file_cache max=1000 inactive=20s;
#open_file_cache_valid 30s;
#open_file_cache_min_uses 2;
#open_file_cache_errors on;
log_format json escape=json '{"@timestamp":"$time_iso8601",'
'"server_addr":"$server_addr",'
'"remote_addr":"$remote_addr",'
'"scheme":"$scheme",'
'"request_method":"$request_method",'
'"request_uri": "$request_uri",'
'"request_length": "$request_length",'
'"uri": "$uri", '
'"request_time":$request_time,'
'"body_bytes_sent":$body_bytes_sent,'
'"bytes_sent":$bytes_sent,'
'"status":"$status",'
'"upstream_time":"$upstream_response_time",'
'"upstream_host":"$upstream_addr",'
'"upstream_status":"$upstream_status",'
'"host":"$host",'
'"http_referer":"$http_referer",'
'"http_user_agent":"$http_user_agent"'
'}';
######################## default ############################
server {
listen 80;
server_name _;
access_log /data/wwwlogs/access_nginx.log combined;
root /data/wwwroot/default;
index index.html index.htm index.php;
#error_page 404 /404.html;
return 301 https://$host$request_uri;
}
########################## vhost #############################
include vhost/*.conf;
}
b. nginx.conf中添加stream配置
stream {
log_format proxy '$proxy_protocol_addr $remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time "$upstream_addr" "$ssl_preread_server_name" '
'"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';
access_log /usr/local/nginx/logs/access.log proxy;
error_log /usr/local/nginx/logs/error.log info;
# 服务器配置
map_hash_bucket_size 64;
map $ssl_preread_server_name $backend_pool {
www.notion.so server_notion;
s3.us-west-2.amazonaws.com server_s3;
msgstore.www.notion.so server_msg;
notion.so server_n;
}
upstream server_msg {
server msgstore.www.notion.so:443 ;
}
upstream server_n {
server notion.so:443;
}
upstream server_notion{
server www.notion.so:443;
}
upstream server_s3{
server s3.us-west-2.amazonaws.com:443;
}
# 限速
map $ssl_preread_server_name $upspeed{
www.notion.so 1024k;
s3.us-west-2.amazonaws.com 512k;
msgstore.www.notion.so 256k;
notion.so 256k;
}
map $ssl_preread_server_name $downspeed{
www.notion.so 1024k;
s3.us-west-2.amazonaws.com 256k;
msgstore.www.notion.so 256k;
notion.so 256k;
}
server{
listen 443;
ssl_preread on;
proxy_pass $backend_pool;
proxy_connect_timeout 15s;
proxy_timeout 15s;
proxy_next_upstream_timeout 15s;
# 取消限速
# proxy_download_rate $downspeed;
# proxy_upload_rate $upspeed;
}
}
3> PC端修改host文件
192.168.1.100为示例ip
192.168.1.100 www.notion.so
192.168.1.100 msgstore.www.notion.so
4> pc端notion添加http代理
–proxy-server=http:// 192.168.1.100:8090
![图片[1]-L31※nginx反向代理为Notion加速-霜林轩](https://www.chiles.top/wp-content/uploads/2022/10/image-2.png)
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END