logo
当前位置:首 页 > 编程技术 >后端开发 >nginx > 查看文章

nginx配置站点(swoole)

nginx, 后端开发, 编程技术 你是第164个围观者 0条评论 供稿者: 标签:,
  1. # 本地调试模拟域名
  2. server{
  3. # gzip用来压缩前端文件体积
  4. gzip on;
  5. gzip_min_length 1024;
  6. gzip_buffers 4 16k;
  7. gzip_comp_level 9;
  8. gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png application/javascript;
  9. gzip_vary on;
  10.  
  11. # 上传文件大小
  12. client_max_body_size 5m;
  13. listen 80;
  14. # 输入您的域名 t.fashop.cn 只为演示代码,如果您没有域名可以在本地的host里进行模拟,加一行 127.0.0.1 t.fashop.cn,这样就拦截了这个域名跳到本地项目,请尽可能的模拟线上环境
  15. server_name t.fashop.cn;
  16.  
  17. fastcgi_connect_timeout 300;
  18. fastcgi_send_timeout 300;
  19. fastcgi_read_timeout 300;
  20.  
  21. # 映射到swoole端口
  22. location / {
  23. proxy_pass http://127.0.0.1:9510;
  24. proxy_redirect off;
  25. proxy_set_header Host $host;
  26. proxy_set_header X-Real-IP $remote_addr;
  27. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  28. proxy_http_version 1.1;
  29. proxy_set_header Upgrade $http_upgrade;
  30. proxy_set_header Connection "upgrade";
  31.  
  32. proxy_connect_timeout 300s;
  33. proxy_send_timeout 300s;
  34. proxy_read_timeout 300s;
  35.  
  36. }
  37. # 上传资源
  38. location ~/Upload/.*\.(gif|jpg|jpeg|png|txt|mp3|mp4|rmvb|mkv|avi|mov|MOV|json|ico|css|js)$ {
  39. root /var/www/fashop/;
  40. }
  41.  
  42. # 前端项目资源匹配
  43. location ~/manifest.json$ {
  44. root /var/www/fashop/a/;
  45. }
  46. # 前端项目资源匹配
  47. location ~/favicon.ico$ {
  48. root /var/www/fashop/a/;
  49. }
  50. # 前端项目资源匹配
  51. location ~/logo.png {
  52. root /var/www/fashop/a/;
  53. }
  54. # 前端项目资源匹配
  55. location ~/logo-black.png {
  56. root /var/www/fashop/a/;
  57. }
  58. # 前端项目资源匹配
  59. location ~/static/.*\.(gif|jpg|jpeg|png|txt|mp3|mp4|rmvb|mkv|avi|mov|MOV|json|ico|css|js)$ {
  60. root /var/www/fashop/a/;
  61. }
  62. # 前端项目资源匹配
  63. location ~(/a$|/a/) {
  64. root /var/www/fashop/;
  65. try_files $uri /a/index.html;
  66. }
  67. }

 

宝塔

 

  1. server
  2. {
  3. listen 80;
  4. listen 443 ssl http2;
  5. server_name wu88h.cn www.wu88h.cn swoole.csdingding.com;
  6. index index.php index.html index.htm default.php default.htm default.html;
  7. root /www/wwwroot/wu88h.cn;
  8.  
  9. #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则
  10. #error_page 404/404.html;
  11. ssl_certificate /etc/letsencrypt/live/wu88h.cn/fullchain.pem;
  12. ssl_certificate_key /etc/letsencrypt/live/wu88h.cn/privkey.pem;
  13. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  14. ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
  15. ssl_prefer_server_ciphers on;
  16. ssl_session_cache shared:SSL:10m;
  17. ssl_session_timeout 10m;
  18. error_page 497 https://$host$request_uri;
  19.  
  20.  
  21.  
  22.  
  23. # 映射到swoole端口
  24. location / {
  25. proxy_pass http://127.0.0.1:9501;
  26. proxy_redirect off;
  27. proxy_set_header Host $host;
  28. proxy_set_header X-Real-IP $remote_addr;
  29. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  30. proxy_http_version 1.1;
  31. proxy_set_header Upgrade $http_upgrade;
  32. proxy_set_header Connection "upgrade";
  33.  
  34. proxy_connect_timeout 300s;
  35. proxy_send_timeout 300s;
  36. proxy_read_timeout 300s;
  37.  
  38. }
  39.  
  40.  
  41. # 前端项目资源匹配
  42. location ~/static/.*\.(gif|jpg|jpeg|png|txt|mp3|mp4|rmvb|mkv|avi|mov|MOV|json|ico|css|js)$ {
  43. root /www/wwwroot/luo/cmf/thinkcmf51_dev/public/;
  44. }
  45.  
  46.  
  47. #SSL-END
  48.  
  49. #ERROR-PAGE-START 错误页配置,可以注释、删除或修改
  50. error_page 404 /404.html;
  51. error_page 502 /502.html;
  52. #ERROR-PAGE-END
  53.  
  54. #PHP-INFO-START PHP引用配置,可以注释或修改
  55. include enable-php-72.conf;
  56. #PHP-INFO-END
  57.  
  58. #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
  59. include /www/server/panel/vhost/rewrite/wu88h.cn.conf;
  60. #REWRITE-END
  61.  
  62. #禁止访问的文件或目录
  63. location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
  64. {
  65. return 404;
  66. }
  67.  
  68. #一键申请SSL证书验证目录相关设置
  69. location ~ \.well-known{
  70. allow all;
  71. }
  72.  
  73. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  74. {
  75. expires 30d;
  76. error_log off;
  77. access_log /dev/null;
  78. }
  79.  
  80. location ~ .*\.(js|css)?$
  81. {
  82. expires 12h;
  83. error_log off;
  84. access_log /dev/null;
  85. }
  86. access_log /www/wwwlogs/wu88h.cn.log;
  87. error_log /www/wwwlogs/wu88h.cn.error.log;
  88. }

 

 

 

 

 

 

 

 

 

说说梦想,谈谈感悟 ,聊聊技术 https://github.com/cjx2328

—— 陈 建鑫

陈建鑫
你可能也喜欢Related Posts
footer logo
未经许可请勿自行使用、转载、修改、复制、发行、出售、发表或以其它方式利用本网站之内容。站长联系:cjx2328#126.com(修改#为@)
Copyright ©ziao design Studio All Rights Reserved.沪ICP备14052271号-3