参考: https://blog.csdn.net/qq_44089649/article/details/112251575

    1. #user nobody;
    2. worker_processes 1;
    3. #error_log logs/error.log;
    4. #error_log logs/error.log notice;
    5. #error_log logs/error.log info;
    6. #pid logs/nginx.pid;
    7. events {
    8. worker_connections 1024;
    9. }
    10. http {
    11. include mime.types;
    12. default_type application/octet-stream;
    13. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    14. # '$status $body_bytes_sent "$http_referer" '
    15. # '"$http_user_agent" "$http_x_forwarded_for"';
    16. #access_log logs/access.log main;
    17. sendfile on;
    18. #tcp_nopush on;
    19. #keepalive_timeout 0;
    20. keepalive_timeout 65;
    21. #gzip on;
    22. server {
    23. listen 80;
    24. server_name hw.tannn.cn;
    25. #charset koi8-r;
    26. #access_log logs/host.access.log main;
    27. location / {
    28. root html;
    29. index index.html index.htm;
    30. }
    31. error_page 500 502 503 504 /50x.html;
    32. location = /50x.html {
    33. root html;
    34. }
    35. }
    36. server {
    37. listen 80;
    38. server_name download.tannn.cn;
    39. #charset koi8-r;
    40. #access_log logs/host.access.log main;
    41. location / {
    42. alias /tn/download/; # 文件目录
    43. sendfile on;
    44. autoindex on; # 开启目录文件列表
    45. autoindex_exact_size on; # 显示出文件的确切大小,单位是bytes
    46. autoindex_localtime on; # 显示的文件时间为文件的服务器时间
    47. charset utf-8,gbk; # 避免中文乱码
    48. }
    49. error_page 500 502 503 504 /50x.html;
    50. location = /50x.html {
    51. root html;
    52. }
    53. }
    54. }