一:网站转发
#like12 add,20220630,网站转发
server {
listen 80;
server_name www.xxxx.com;
client_max_body_size 100m;
location / {
root html;
index index.html index.htm;
#like12 add,20220711,单纯的重定向
return 302 http://net.xxxx.com;
#proxy_pass http://net.xxxx.com;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
参考:https://www.jb51.net/article/243925.htm
二、解决server_name太长时报错
问题:nginx启动报错:
could not build server_names_hash, you should increase server_names_hash_bucket_size: 32
解决办法:
server_names_hash_bucket_size 64;
events { worker_connections 1024; } http { #like12 add,20220724,解决server_name太长时报错 server_names_hash_bucket_size 64; include mime.types; default_type application/octet-stream;
三、上传文件大小限制 默认1M
client_max_body_size 100m;
server {
listen 443 ssl;
server_name tie.ztejjx.com;
client_max_body_size 100m;
三、nginx alias取别名【root与alias的区别】
#Web前端静态资源
location / {
#注意:这里的路径指的是Docker内部的路径 而非外部宿主机的挂载路径
root /html;
index index.html index.htm;
}
#图片静态资源
location /image-bftf/ {
alias /data/image_bftf/;
}
四、linux安装nginx后报403【或401】无权限
改nginx.conf第一行内容“#user nobody;”为“user root;”试试