Nginx参数站点配置上的问题解决方案 - Go语言中文社区

Nginx参数站点配置上的问题解决方案


Nginx参数有很多经典的语句,其中upstream.conf 配置文件就是一个很好的例子,下面我们就看看如何才能好的使用这些语句呢?下面的文章就会对你有很好的帮助,尤其是在了解Nginx参数上的问题。

  1. upstream.conf  
  2. upstream bbs.linuxtone.com {  
  3. server 192.168.1.4:8099;  

Nginx参数站点配置文件

  1. bbs.linuxtone.conf  
  2. server  
  3. {  
  4. listen 80;  
  5. server_name bbs.linuxtone.conf;  
  6. charset GB2312;  
  7. index index.html index.htm;  
  8. root /date/wwwroot/linuxtone/;  
  9.  
  10. location ~ ^/NginxStatus/ {  
  11. stub_status on;  
  12. access_log off;  
  13. }  
  14. location / {  
  15. root /date/wwwroot/linuxtone/;  
  16. proxy_redirect off ;  
  17. proxy_set_header Host $host;  
  18. proxy_set_header X-Real-IP $remote_addr;  
  19. proxy_set_header REMOTE-HOST $remote_addr;  
  20. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  
  21. client_max_body_size 50m;  
  22. client_body_buffer_size 256k;  
  23. proxy_connect_timeout 30;  
  24. proxy_send_timeout 30;  
  25. proxy_read_timeout 60;  
  26. proxy_buffer_size 256k;  
  27. proxy_buffers 4 256k;  
  28. proxy_busy_buffers_size 256k;  
  29. proxy_temp_file_write_size 256k;  
  30. proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;  
  31. proxy_max_temp_file_size 128m;  
  32. proxy_pass http://bbs.linuxtone.com;  

Nginx参数都有所调整.目的是解决代理过程中出现的一些502 499错误

  1. #Add expires header for static content  
  2. location ~* .(jpg|jpeg|gif|png|swf)$ {  
  3. if (-f $request_filename) {  
  4. root /date/wwwroot/linuxtone/;  
  5. expires 1d;  
  6. break;  
  7. }  
  8. }  
  9. log_format access '$remote_addr - $remote_user [$time_local] "$request" '  
  10. '$status $body_bytes_sent "$http_referer" '  
  11. '"$http_user_agent" $http_x_forwarded_for';  
  12. access_log /exp/Nginxlogs/bbs.linuxtone_access.log access;  

以上就是对Nginx参数的详细介绍,希望大家有所帮助。

版权声明:本文来源51CTO,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:http://developer.51cto.com/art/201003/191493.htm
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2021-05-16 03:38:04
  • 阅读 ( 727 )
  • 分类:Go Web框架

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢