Ê×Ò³ > ½Ì³Ì > EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

ʱ¼ä£º2024-04-08¡¡|¡¡À´Ô´£º¡¡|¡¡ÔĶÁ£º104

»°Ì⣺ È« ÃÎ edge »Ã Ãλà One AI È«Çò °²È«

±¾ÆªÎÄÕÂÔ´ÓÚËûÈË´´ÒâµÄÆô·¢ÓëÉîÈë˼¿¼£¬ÎÒͶÈëÁË´óÁ¿Ê±¼äÓ뾫Á¦£¬ÖÂÁ¦ÓÚEdgeOneÓëHAIÖ®¼äµÄЭͬµ÷ÊÔ£¬¿Ë·þÁËÖڶ༼ÊõÆæÝâÎÊÌ⡣ͨ¹ý²»Ð¸µÄŬÁ¦£¬³É¹¦µØ½«ÕâÁ½¸öÇ¿´óµÄƽ̨ÕûºÏÔÚÒ»Æ𣬴òÔì³öÒ»¸ö»¹²»´íµÄ²Î¿¼°¸Àý¡£Õâ´Î̽Ë÷Ò²ÊÇÎÒ¸öÈËÊ×´ÎÉæ×ã±ßÔµº¯Êýʽ²úÆ·µÄʵ¼ùÖ®Âá£ÎÒÏ£Íûͨ¹ý·ÖÏíÕâ´ÎµÄ¾­ÀúºÍ³É¹û£¬Äܹ»¼¤

ÔÚµ±½ñ¿ìËÙ·¢Õ¹µÄÊý×Öʱ´ú£¬°²È«ºÍËÙ¶ÈÒѳÉΪÍøÂç·þÎñµÄ»ùʯ¡£EdgeOne£¬×÷ΪÌÚѶÔÆÌṩµÄ±ßÔµ°²È«¼ÓËÙƽ̨£¬ÒÔÆäÈ«Çò²¿ÊðµÄ½ÚµãºÍÇ¿´óµÄ°²È«·À»¤¹¦ÄÜ£¬ÎªÓû§ÌṩÁËÎȶ¨¶ø¸ßЧµÄÍøÂçÌåÑé¡£¶øHAI£¨HyperApplicationInventor£©£¬ÌÚѶÔÆÍƳöµÄ¸ßÐÔÄÜÓ¦Ó÷þÎñ£¬Í¨¹ýÆäÒ×ÓõÄͼÐλ¯½çÃæºÍ·á¸»µÄÄ£ÐͿ⣬ʹµÃAIÓ¦Óÿª·¢±äµÃ´¥Êֿɼ°¡£±¾ÎĽ«Ì½ÌÖEdgeOneÓëHAIµÄ½áºÏÈçºÎΪÓû§Ìṩһ¸ö¼È°²È«ÓÖ¸ßЧµÄAIÓ¦Óÿª·¢»·¾³¡£


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

  1. DDoS·À»¤£ºEdgeOneʹÓÃAnycast¼Ü¹¹ÔÚÈ«Çò½¨Á¢³¬¹ý25¸öÇåÏ´ÖÐÐÄ£¬ÄÜ¿ìËÙ¼ì²â²¢Çå³ýÍøÂç¡¢´«ÊäºÍÓ¦ÓòãµÄDDoS¹¥»÷¡£
  2. WEB¹¥»÷·À»¤£ºEdgeOneÓµÓй㷺µÄ¹¥»÷ÌØÕ÷¿â£¬¸²¸ÇÖ÷ÒªµÄ°²È«Íþв£¬ÄÜ×èÖ¹¸÷ÀàWeb¹¥»÷²¢·ÀÓù0day©¶´£¬Í¨¹ýAIÌá¸ß¼ì²â׼ȷÐÔ£¬¼õÉÙÎ󱨡£
  3. ÖÇÄÜCCʶ±ð£ºEdgeOneÀûÓöàÄê¾­Ñ飬ͨ¹ý·ÖÎöÍøÂçÁ÷Á¿ºÍ¶àÖÖ²ÎÊý£¬×Ô¶¯Ê¶±ð²¢¶¨Î»¹¥»÷Ô´£¬ÓÐЧ¶Ô¿¹CC¹¥»÷¡£
  4. BOT·À»¤£ºEdgeOneͨ¹ýЭÒé¡¢IPºÍ»á»°ÌØÕ÷ʶ±ðBOT£¬½áºÏÊý¾Ý·ÖÎö½¨Á¢Ä£ÐÍ£¬·ÀÖ¹¶ñÒâÅÀ³æ¹¥»÷£¬¼õÉÙ¶ÔÕý³£ÅÀ³æµÄÎóÉË¡£
  5. ¹¥»÷ËÝÔ´£ºEdgeOne¿ÉÒÔ²¶»ñ²¢·ÖÎöÒ쳣ʼþ£¬ÌáÈ¡¹¥»÷ÐÅÏ¢£¬Ìṩ¼à¿ØÒ³Ãæչʾ¹¥»÷ÏêÇ飬°ïÖúÓû§µ÷Õû·À»¤²ßÂÔ¡£
  6. È«Ììºò¼à²â£ºÌÚѶ°²È«ÍŶÓ24/7ʵʱ¼à¿Ø£¬Ö÷¶¯·¢ÏÖ²¢Ó¦¶ÔÍþв£¬¿ìËÙÏìÓ¦°²È«Ê¼þ¡£

²»¶à˵ÁË£¬Ê£ÏµÄÄÚÈݶ¼ÒѾ­ÔÚ¹Ù·½ÎĵµÖÐÓÐÏêϸÃèÊö¡£¾ÍÎÒÃǸöÈ˶øÑÔ£¬EdgeOne¾ßÓÐÒÔÏÂÖ÷ÒªÓŵ㣬²¢ÇÒÎÒÒ²¸½ÉÏÁËÐèÒªµÄ¹Ø¼üÎĵµµØÖ·£º

HAI£ºAIÓ¦ÓõĿìËÙ¿ª·¢

HAIÌṩÁË¿ÉÊÓ»¯½»»¥½çÃ棬֧³ÖJupyterLab¡¢WebUIµÈ¶àÖÖËãÁ¦Á¬½Ó·½Ê½£¬Ê¹µÃÓû§¼´Ê¹Ã»ÓÐÉîºñµÄ±à³Ì±³¾°Ò²ÄÜÇáËÉ¿ª·¢AIÓ¦Óá£ÕâÖÖ¡°ÓÐÊÖ¾ÍÄÜ¿ª·¢¡±µÄÉè¼ÆÀíÄ¼«´óµØ½µµÍÁËAI¼¼ÊõµÄÓ¦ÓÃÃż÷¡£Ö§³ÖѧÊõ¼ÓËÙ£¬Í¨¹ýÏß·×Ô¶¯ÔñÓÅ£¬Äܹ»´ó·ùÌáÉýÖ÷Á÷ѧÊõ×ÊԴƽ̨µÄ·ÃÎÊ¡¢ÏÂÔØËٶȡ£Í¬Ê±£¬HAIԤװÁËStableDiffusion¡¢ChatGLMµÈÈÈÃÅÄ£ÐÍ£¬Óû§¿ÉÒÔÔÚÊý·ÖÖÓÄÚ¹¹½¨×Ô¼ºµÄ´óÓïÑÔÄ£ÐÍ¡¢AI×÷»­µÈÓ¦Óû·¾³¡£

Õâ¸ö»°Ìâ²»ÐèÒªÏêϸÌÖÂÛÁË£¬ÎÒÒѾ­ÕûÀíÁË¿ª·¢ÖÐÐèÒªÁ˽âµÄÖ÷ÒªÓŵãºÍÏà¹ØÎĵµ£¬ÒÔ±ã´ó¼ÒÄܹ»¿ìËÙÈëÊÖ¿ª·¢£º

  1. ¿ìËÙ²¿Ê𣺴´½¨¸ßÐÔÄÜÓ¦Ó÷þÎñʵÀý£¬Ñ¡ÔñºÏÊʵĵØÓò¡¢ËãÁ¦·½°¸£¬²¢ÉèÖÃʵÀýÃû³ÆºÍÓ²Å̿ռ䡣¹Ù·½Îĵµ£º https://cloud.tencent.com/document/product/1721/101036
  2. Éú³ÉAPIÎĵµ£ºÔÚÒѲ¿ÊðµÄStable DiffusionÓ¦Óûù´¡ÉÏ£¬Í¨¹ýJupyterLab²¿ÊðAPI·þÎñ¡£¹Ù·½Îĵµ£º https://cloud.tencent.com/document/product/1721/102198
  3. Ä£ÐÍÏÂÔصØÖ·£º https://civitai.com/
  4. µ¼ÈëÍⲿģÐÍ£ºÔÚÌÚѶÔƸßÐÔÄÜÓ¦Ó÷þÎñHAIÉÏ£¬¿ÉÒÔͨ¹ýÈýÖÖ·½Ê½µ¼ÈëÍⲿģÐÍ£¬µ«ÊÇΪÁË»¨Ç®ÉÙÒ»µã£¬ÎÒÍƼöÄãÑ¡ÔñCOS´æ´¢¡£¹Ù·½Îĵµ£º https://cloud.tencent.com/document/product/1721/102523#1bb64c7b-0bc8-4a2a-86f0-ad0e71d8f059

Áª¶¯¿ª·¢

ÏÖÔÚÈÃÎÒÃÇÀ´Ì½ÌÖÒ»ÏÂΪºÎ¿ÉÒÔ²ÉÓÃÁª¶¯¿ª·¢µÄ·½Ê½¡£ÎÒÃǵÄÄ¿±êÊÇÒÔ×îΪ¾­¼Ãʵ»ÝµÄ¼Û¸ñ²¿ÊðÎÒÃǵÄAI»æ»­Ó¦Óá£

  1. HAI¸ßÐÔÄÜ·þÎñÆ÷ÊÇ°´ÕÕСʱÊշѵģ¬ËùÒÔÎÒÃǺܶàÇé¿öÏ»áÑ¡Ôñ¹Ø»ú£¬µ«ÊÇÒ»µ©ÖØÆô·þÎñÆ÷£¬ÍâÍøIP¾Í»á±ä¶¯£¬µ¼ÖÂÄãµÄ·ÃÎÊ·¾¶Ò²¾ÍËæÖ®±ä»»¡£µ«ÊÇÕâÒ»²½¿ÉÒÔÔÚEdgeOneÖÐʹÓñßÔµº¯Êý½â¾ö¡£
  2. EdgeOne±¾Éí¾ÍÒѾ­¶ÔÎÒÃǵķþÎñÆ÷×öÁËÏàÓ¦µÄ°²È«·À»¤¡£
  3. HAI¸ßÐÔÄÜ·þÎñÆ÷£¬ËûÊÇÒ»¸öUbuntu20.04»·¾³µÄÐéÄâ»ú£¬Ò²¾ÍÊÇ˵£¬ÎÒÃÇÒѾ­ÓÐÁËÒ»¸ö·þÎñÆ÷£¬Ö»²»¹ýÕâ¸ö·þÎñÆ÷±»°ü×°³ÉÁ˻滭AIÓ¦Óã¬ËùÒÔ²»ÒªÀ˷ѵô¡£ÓÃÆðÀ´

ÎÒÃǽÓÏÂÀ´¿´ÏÂÎÒÃÇ»áÓõ½ÄÄЩ¼¼Êõ£ºHTML¡¢Javascript¡¢CSS¡¢Nginx¡¢Python¡¢±ßÔµº¯ÊýÖеĸ÷¸öAPI¡¢Linux»ù±¾ÃüÁî¡£

×¼±¸»·¾³

HAI¸ßÐÔÄÜ·þÎñÆ÷

¹ØÓÚ´´½¨·þÎñÆ÷µÄ²½Ö裬ÎҾͲ»ÔÙ½øÐÐÑÝʾÁË£¬ÇëÖ±½Ó²é¿´¹Ù·½½Ì³Ì£¬Ïà¹ØµØÖ·Ò²ÒѾ­Ìṩ¡£ÎÒÃǽ«ÖصãÑÝʾÒÔÏÂÄÚÈÝ£ºÏÂÔØ/ÉÏ´«Ä£ÐÍ¡¢Í¨¹ýWEB UIÑÝʾAI»æ»­¹¦ÄÜ¡¢ÏÂÔز¢ÅäÖÃNginxÒÔ¼àÌý80¶Ë¿Ú¡¢Æô¶¯API½Ó¿Ú·þÎñ¡£

ÏÂÔØ/ÉÏ´«Ä£ÐÍ

ÕâÒ»²½ÎÒµ±Ê±Ê¹ÓùýÈçºÎ¹Ù·½Ä¬ÈϵÄJupyterLabÒ³ÃæÉÏ´«£¬ËÙ¶ÈÊÇÕæµÄºÜ¿É¹Û~ÎÒÖ±½Ó·ÅÆúÁË¡£Ñ¡ÔñÁËCOS¶ÔÏó´æ´¢¡£ÎÒÃÇÏÈÈ¥ÏÂÔغÿ´µÄÄ£ÐÍ¡£ÕâÀïÒÔhttps://civitai.com/ ΪÀý¡£


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

Ä£ÐÍÏÂÔص½±¾µØÖ®ºó£¬È¥´´½¨COS¶ÔÏó´æ´¢·þÎñ¡£

ÈçºÎ´´½¨Õâô¼òµ¥µÄ½Ì³Ì£¬ÎҾͲ»ÑÝʾÁË£¬ÎÒÃÇÖ±½Ó¿´ÉÏ´«ºÍÏÂÔØ¡£ÕâÀï´´½¨´æ´¢Í°µÄʱºò£¬ËùÊôµØÓòÒ»¶¨ÒªºÍÄãHAI»æ»­·þÎñÆ÷ÔÚÒ»Æð¡£·ñÔò»á²úÉúºÜ¶à¶îÍâµÄ»¨Ïú¡£½÷¼Ç~


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

½øÈë´æ´¢Í°Ö®ºó£¬Ö±½Óµã»÷Ò³ÃæµÄÉÏ´«Îļþ¼´¿É£¬ÇëÑ¡Ôñ¸Õ²ÅÏÂÔصÄÄ£ÐÍÎļþ¡£ÉÏ´«µÄ¹ý³ÌÖв»Òª¶¯ä¯ÀÀÆ÷£¬Ò»µ©Ë¢Ðº͹رÕä¯ÀÀÆ÷¾Í»áÇ°¹¦¾¡Æú¡£


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

ÉÔµÈƬ¿Ì£¬È»ºóµã»÷Ä£ÐÍÎļþµÄÏêÇ飬½øÈë»ù±¾ÐÅÏ¢Ò³Ãæ¡£ÔÚÕâÀÇëÈ·±£½«È¨ÏÞÉèÖÃΪ¹«ÓжÁÈ¡£¬·ñÔòHAI·þÎñÆ÷½«ÎÞ·¨ÏÂÔص½Ä£ÐÍÎļþ¡£È»ºó£¬¸´ÖÆÁÙʱÁ´½Ó¡£


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

ÎÒÃǽøÈëÒѾ­´´½¨ºÃµÄHAI·þÎñÆ÷¡£


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

½øÈëÖնˣ¬Ê¹ÓÃһϼ¸¸öÃüÁÏÂÔØÄ£ÐÍÎļþµ½Ä£ÐÍÎļþ¼Ð¡£

cd stable-diffusion-webui/models/Stable-diffusion

wget ÁÙʱÁ´½ÓÕ³Ìùµ½´Ë´¦

µÈ´ýÏÂÔØÍê±Ï¡£

WEB UIÑÝʾAI»æ»­

ÈÃÎÒÃÇÇ°ÍùWEB UIÒ³Ã棬³¢ÊÔһϿ´¿´ÊÇ·ñ³É¹¦°²×°ÁË¡£


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

ÔÚWEB UIÒ³ÃæÉÏ£¬Ñ¡ÔñÄú×Ô¼ºµÄÄ£ÐÍÎļþ£¬²¢Ê¹ÓÃÒ»¶ÎÉñÆæµÄÌáʾ´Ê¡£µ±È»£¬Ìáʾ´ÊÔ½ºÃ£¬Éú³ÉµÄ½á¹ûÒ²»áÔ½ºÃ¡£Èç¹ûÓÐÈκβ»Çå³þµÄµØ·½£¬Äú¿ÉÒԲο¼ÄúÏÂÔصÄÄ£Ð͸½´øµÄ½Ì³Ì¡£ÕâÑù»ù±¾ÉϾÍûÓÐÎÊÌâÁË¡£½ÓÏÂÀ´£¬ÈÃÎÒÃÇÔÙÀ´¿´¿´ÈçºÎÈÃHAIÌṩվµã·þÎñ¡£

NginxÕ¾µãÅäÖÃ

ÒÀÈ»ÊÇͬÑùµÄ²½Ö裬ÔÚJupyterLabÖеÄÖÕ¶ËÖÐÖ±½ÓʹÓÃÒÔÏÂÃüÁî²Ù×÷£º

  1. ÏÂÔØNginx£ºÊ¹ÓÃÃüÁî apt install nginx ½øÐа²×°¡£
  2. Æô¶¯Nginx£ºÊ¹ÓÃÃüÁî service nginx start Æô¶¯·þÎñ¡£

µ±ÄúÖ±½ÓʹÓÃIPµØÖ·ÔÚä¯ÀÀÆ÷ÖзÃÎʺó£¬Èç¹ûÏÔʾÒÔϽçÃ棬ÄǾͱíʾ°²×°³É¹¦ÁË¡£


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

½ÓÏÂÀ´£¬ÎÒÃǼÌÐøÐÞ¸ÄNginxµÄÅäÖÃÎļþ£º
ʹÓÃÒÔÏÂÃüÁî±à¼­ÅäÖÃÎļþ£º

vim /etc/nginx/sites-available/default

È»ºó£¬ÔÚÎļþÖÐÌí¼ÓÒÔÏÂÅäÖãº


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

# ÅäÖÃ/images·¾¶µÄ·ÃÎʹæÔò
location /images/  {
            add_header 'Access-Control-Allow-Origin' "$http_origin";
            add_header 'Access-Control-Expose-Headers' 'strict-origin-when-cross-origin';
            alias   /root/stable-diffusion-webui/outputs/star/images/;  # ÄãµÄ¾²Ì¬Ò³Ãæ
            expires 1d;
            }
location /sdapi/  {
      # Add CORS headers
     add_header 'Access-Control-Allow-Origin' '*' always;
     add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
     add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range' always;
    add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always;
    proxy_pass  http://127.0.0.1:7862/sdapi/;
    if ($request_method = "OPTIONS"){
            return 200;
        }
    }

ÕâÀïÅäÖÃÁË/images·¾¶µÄ·ÃÎʹæÔòÒÔ¼°API·þÎñµÄ´úÀí¡£ÎªÊ²Ã´ÒªÅäÖôúÀíÄØ£¿ÕâÏÔÈ»ÊÇÒòΪ»æ»­µÄAPI·þÎñ²»Ö§³Ö¿çÓò·ÃÎÊ£¬ËùÒÔÎÒÃÇÌí¼ÓÁËÒ»¸ö·´Ïò´úÀí¡£ÓÉÓÚÎÒÃǵÄÇëÇóÊÇPOST·Ç¼òµ¥ÇëÇó£¬Òò´Ëä¯ÀÀÆ÷»¹»á·¢ËÍÒ»¸öOPTIONSµÄÔ¤¼ìÇëÇó¡£ÎÒÒ²×öÁËÏàÓ¦µÄ´¦Àí¡£ÒÔÃâ¿çÓò±¨´í¡£

ÐÞ¸ÄÍê³Éºó£¬Ê¹ÓÃÃüÁî service nginx reload À´ÖØмÓÔØNginxµÄÅäÖá£Äú¿ÉÒÔ¿´µ½ÎÒÃÇÅäÖõÄ/images·¾¶¶ÔÓ¦µÄÎļþ¡£Õâ¸ö·¾¶Äú¿ÉÒÔËæÐÄÅäÖã¬Ö»ÒªÈ·±£ÆäÖаüº¬Äú×Ô¼ºµÄͼƬ¼´¿É¡£Äú¿ÉÒÔÑ¡Ôñ×Ô¼ºÎ¬»¤ÕâЩͼƬ£¬Ò²¿ÉÒÔͨ¹ý³ÌÐòÉú³É¡£ÎªÁËÑÝʾ£¬ÎÒÖ»¼òµ¥¸´ÖÆÁ˼¸ÕÅÎÒʹÓÃAI»æ»­³öÀ´µÄͼƬ¡£


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

ÈÃÎÒÃÇͨ¹ýNginxÀ´·ÃÎÊÒ»ÏÂͼƬ£¬ÒÔÈ·±£¿ÉÒÔÕý³£·ÃÎÊ¡£

ÔÚä¯ÀÀÆ÷ÖÐÊäÈëÒÔϵØÖ·½øÐзÃÎÊ£º http://ÄãµÄIP/images/1.png


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

½ÓÏÂÀ´£¬ÎÒÃǼÌÐøµ÷ÊÔAPI·þÎñ¡£ÇëÆô¶¯HAI»æ»­Ó¦ÓõÄAPI·þÎñ£¬Ê¹ÓÃÒÔÏÂÃüÁ

python launch.py --nowebui --xformers --opt-split-attention --listen --port 7862

È»ºó£¬ÔÚä¯ÀÀÆ÷ÖÐÊäÈëIPµØÖ·ºÍ¶Ë¿ÚºÅ£¬ºóÃæ¼ÓÉÏ/docs·¾¶¼´¿ÉÕý³£·ÃÎÊ·¾¶ÁË¡£


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

ÈÃÎÒÃÇͨ¹ý¹¤¾ßÀ´²âÊÔһϣ¬¿´¿´ÄÜ·ñͨ¹ýNginxÕý³£·ÃÎʽӿڡ£Äã¿ÉÒÔËæÒâÑ¡ÔñÒ»¸ö½Ó¿Ú·¾¶½øÐвâÊÔ¡£ÎÒÑ¡ÔñÁËÒ»¸ö¼òµ¥µÄÎÞÇëÇó²ÎÊýµÄGETÇëÇó×÷ΪʾÀý¡£Í¨³£Çé¿öÏ£¬Õâ¸öÇëÇó»á´øÓж˿ںš£


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

ʹÓõ÷ÊÔ¹¤¾ßÀ´µ÷ÓÃÒ»ÏÂNginxÅäÖõÄ·¾¶£¬È·±£Ò»ÇÐÕý³£¡£


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

Èç¹ûÄú»¹²»È·¶¨µÄ»°£¬¿ÉÒÔͨ¹ý²é¿´Ä¬ÈϵÄNginx·ÃÎÊ·¾¶À´È·ÈÏ¡£Äú¿ÉÒÔʹÓÃÒÔÏÂÃüÁîÀ´ÊµÊ±²é¿´ÈÕÖ¾£º

tail -f /var/log/nginx/access.log

ÕâÑùÄú¾Í¿ÉÒÔÈ·¶¨APIÊÇ·ñÄܹ»±»ÕýÈ·ÃüÖС£


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

Æô¶¯API½Ó¿Ú·þÎñ

ΪÁ˽â¾öNginxÿ´Î¹Ø»úºóÎÞ·¨Õý³£Æô¶¯µÄÄÑÌ⣬ÎÒÃDzÉÈ¡ÁËÒ»ÏîÇÉÃîµÄ½â¾ö·½°¸£º½«Æô¶¯ÃüÁîÖ±½ÓдÈëAPIÆô¶¯·þÎñ½Ó¿ÚÖУ¬´Ó¶øÈ·±£·þÎñÄܹ»ÔÚÿ´ÎÆô¶¯Ê±ÕýÈ·ÅäÖÃNginx¡£¾ßÌå²Ù×÷ÈçÏ£ºÊ×ÏÈ£¬ÎÒÃÇÐèÒªÕÒµ½ÏîÄ¿ÖеÄlaunch.pyÎļþ¡£Ò»µ©ÕÒµ½Á˸ÃÎļþ£¬ÎÒÃÇÖ»ÐèÔÚÆäÖÐÌí¼Ó¼¸ÐÐÃüÁî¼´¿É¡£ÕâЩÃüÁȷ±£NginxÔÚ·þÎñÆ÷Æô¶¯Ê±µÃµ½ÕýÈ·µÄÅäÖ㬲¢Äܹ»Ë³ÀûÆô¶¯¡£ÕâÖÖ·½·¨¼òµ¥¶ø¸ßЧ£¬Äܹ»ÓÐЧ½â¾öNginxÆô¶¯ÎÊÌ⣬±£Ö¤·þÎñµÄÎȶ¨ÐԺͿɿ¿ÐÔ¡£


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

´úÂëÈçÏ£º

import subprocess

# ´Ë´¦Ê¡ÂԺܶà´úÂë~~
def main():
    # ʹÓÃsubprocess.run()Ö´ÐÐÃüÁî
    result = subprocess.run(['service', 'nginx', 'start'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
    
    # ¼ì²éÃüÁîÊÇ·ñÖ´Ðгɹ¦
    if result.returncode == 0:
        print("Nginx Òѳɹ¦Æô¶¯")
    else:
        print("Æô¶¯ Nginx ʱ³ö´í")
        print("´íÎóÐÅÏ¢:", result.stderr)
        
# ´Ë´¦Ê¡ÂԺܶà´úÂë~~

ΪÁËÑéÖ¤ÎÒÃǵĽâ¾ö·½°¸µÄÓÐЧÐÔ£¬ÈÃÎÒÃÇÔÙ´ÎÖØÐÂÆô¶¯API·þÎñ£¬¹Û²ìÊÇ·ñÄܹ»³É¹¦Æô¶¯Nginx¡£


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

ͨ¹ýÒÔÉϲ½Ö裬ÎÒÃǵÄHAI¸ßÐÔÄÜ·þÎñÆ÷ÒѾ­Íê³ÉÁË»ù±¾ÅäÖá£ÎÞÂÛ½øÐжàÉٴιػúÖØÆô£¬ÎÒÃǵÄNginx¶¼»áËæ×ÅAPI½Ó¿ÚÒ»ÆðÆô¶¯£¬È·±£ÁËϵͳµÄÎȶ¨ÐԺͿɿ¿ÐÔ¡£ÏÖÔÚ£¬ÈÃÎÒÃǼÌÐøÉîÈë̽ÌÖEdgeOneµÄÅäÖùý³Ì¡£

EdgeOne±ßÔµº¯Êý

ÔÚÅäÖÃEdgeOneʱ£¬Ê×ÏÈÐèҪȷ±£Íê³ÉÎÞÓòÃûÕ¾µãµÄÅäÖã¬Äã¿ÉÒÔÖ±½Ó²Î¿¼¹Ù·½Îĵµ½øÐвÙ×÷¡£½Ó×Å£¬ÎÒÃÇÐèÒª´´½¨±ßÔµº¯ÊýÀ´ÊµÏÖÏàÓ¦µÄ»º´æ´¦Àí¡£¿¼Âǵ½ÄãûÓÐÆóÒµ°æȨÏÞ£¬Òò´ËÎÞ·¨Ê¹ÓÃËIJã¼ÓËÙ£¬µ«¿ÉÒÔͨ¹ý±ßÔµº¯ÊýÀ´´ïµ½ÀàËƵÄЧ¹û¡£¹ØÓÚ±ßÔµº¯ÊýÖдúÂëµÄ¾ßÌåʹÓÃÎÊÌ⣬ÎÒ½¨ÒéÄã×ÐϸÔĶÁ¹Ù·½Îĵµ£¬ÆäÖаüº¬ÁËÏêϸµÄ²Ù×÷Ö¸ÄϺÍʾÀý´úÂ룬¿ÉÒÔ°ïÖúÄã¿ìËÙÉÏÊÖ¡£Äã¿ÉÒÔµã»÷ÒÔÏÂÁ´½Ó²é¿´¹Ù·½Îĵµ£º EdgeOne ¹Ù·½Îĵµ


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

ÔÚÅäÖñßÔµº¯Êýʱ£¬Äã¿ÉÒÔÑ¡ÔñHello WorldÄ£°å×÷ΪÆðµã£¬È»ºóÒÀ´Îµã»÷ÏÂÒ»²½½øÐÐÅäÖá£ËäȻѡÔñÁËHello WorldÄ£°å£¬µ«ËüÖ»ÊÇÒ»¸öÆðµã£¬ÎÒÃǽ«ÔÚ´Ë»ù´¡ÉϽøÐÐÉîÈëµÄ¶¨ÖÆ£¬ÒÔʵÏÖÎÒÃÇËùÐèÒªµÄ¹¦ÄÜ¡£


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

Íê³ÉËùÓÐÅäÖúó£¬ÏµÍ³»áΪÄãÉú³ÉÒ»¸öĬÈϵÄÓòÃû¡£½ÓÏÂÀ´£¬ÎÒÃÇÐèÒª±àд´úÂëÀ´ÊµÏÖ¹¦ÄÜ¡£Í¨³£Çé¿öÏ£¬ÎÒ»á¶îÍâ±àдһ¸ötestº¯Êý£¬×¨ÃÅÓÃÓÚ²âÊÔ¡£µ±È»£¬Èç¹ûÄã¾õµÃ²»ÐèÒª£¬Ò²¿ÉÒÔºöÂÔ¡£ÔÚÕâ´ÎÅäÖÃÖУ¬ÎÒÃÇ´´½¨ÁËÁ½¸ö±ßÔµº¯Êý¡£ÕâЩº¯ÊýÒѾ­¾­¹ýÎÒ·â×°£¬Í¨¹ý×îСµÄ±ä¶¯À´Ó¦¶ÔHAI·þÎñÆ÷ÍâÍøIPµÄ±ä»¯£¬È·±£ÁËϵͳµÄÎȶ¨ÐԺͿɿ¿ÐÔ¡£

²éѯͼƬ´¦Àí

Ò»¸ö»æ»­Ó¦ÓõĹؼüÖ®Ò»ÔÚÓÚÄܹ»ÌṩÓÅÖʵÄͼƬչʾ¹¦ÄÜ¡£±Ï¾¹£¬»­×÷µÄÊÓ¾õЧ¹ûÊÇÎüÒýÓû§µÄ¹Ø¼üÖ®Ò»¡£È±ÉÙÁËͼƬչʾ¹¦ÄÜ£¬Õâ¸öÓ¦ÓþͺñÈÊÇÒ»±¾Ã»ÓвåͼµÄ»­²á£¬È±·¦ÎüÒýÁ¦£¬ÄÑÒÔÒýÆðÓû§µÄÐËȤ¡£

async function fetchJquery(event, request) {
  const cache = caches.default;
  // »º´æûÓÐÃüÖУ¬»ØÔ´²¢»º´æ
  let response = await fetch(request);

  // ÔÚÏìӦͷÌí¼Ó Cahe-Control£¬ÉèÖûº´æʱ³¤ 10s
  response.headers.append('Cache-Control', 's-maxage=600');
  event.waitUntil(cache.put(request, response.clone()));

  // δÃüÖлº´æ£¬ÉèÖÃÏìӦͷ±êʶ
  response.headers.append('x-edgefunctions-cache', 'miss');
  return response;
}

async function handleEvent(event) {
  const urlInfo = new URL(event.request.url);
  var url = new URL(event.request.url);
  var ip = url.searchParams.get('ip');
  // ÇëÇó·ÇͼƬ×ÊÔ´
  if (!/\.(jpe?g|png)$/.test(urlInfo.pathname)) {
    return event.respondWith(new Response('Error thrown ûÃüÖÐͼƬURL' + urlInfo.pathname));
  }
  // ×ÊÔ´µØÖ·£¬Ò²×÷Ϊ»º´æ¼ü
  const request = new Request(ip + urlInfo.pathname);
  // »º´æĬÈÏʵÀý
  const cache = caches.default;

  try {
    // »ñÈ¡¹ØÁªµÄ»º´æÄÚÈÝ£¬»º´æ¹ý£¬½Ó¿Úµ×²ã²»Ö÷¶¯»ØÔ´£¬Å׳ö 504 ´íÎó
    let response = await cache.match(request);

    // »º´æ²»´æÔÚ£¬ÖØлñÈ¡Ô¶³Ì×ÊÔ´
    if (!response) {
      return fetchJquery(event, request);
    }

    // ÃüÖлº´æ£¬ÉèÖÃÏìӦͷ±êʶ
    response.headers.append('x-edgefunctions-cache', 'hit');

    return response;
  } catch (e) {
    await cache.delete(request);
    // »º´æ¹ýÆÚ»òÆäËûÒì³££¬ÖØлñÈ¡Ô¶³Ì×ÊÔ´
    return fetchJquery(event, request);
  }
}

addEventListener('fetch', (event) => {
  event.respondWith(handleEvent(event));
});

Õâ¶Î´úÂëµÄÖ÷Òª¹¦ÄÜÊÇÓÃÓÚ´¦ÀíÍøÂçÇëÇó²¢¹ÜÀí×ÊÔ´µÄ»º´æ²ßÂÔ£¬È·±£¿ìËÙÏìÓ¦Óû§ÇëÇóµÄͬʱ£¬¼õÉÙ²»±ØÒªµÄÍøÂçÁ÷Á¿¡£

  1. fetchJquery º¯Êý£º
    • ¸Ãº¯ÊýÓÃÓÚ´¦Àíµ±×ÊԴδ±»»º´æ»ò»º´æ¹ýÆÚʱµÄÇé¿ö¡£
    • ʹÓà fetch º¯Êý·¢ÆðÍøÂçÇëÇ󣬻ñÈ¡×ÊÔ´µÄ×îÐÂÏìÓ¦¡£
    • ÔÚÏìӦͷÖÐÌí¼Ó Cache-Control £¬ÉèÖÃ×ÊÔ´ÔÚ·þÎñ¶Ë»º´æÖеÄ×ÓÐЧʱ¼äΪ600Ãë¡£
    • ʹÓà cache.put ·½·¨½«»ñÈ¡µÄÏìÓ¦¿Ë¡һ·Ý²¢´æÈ뻺´æÖУ¬ÒÔ±ãºóÐøÇëÇó¿ÉÒÔÖ±½Ó´Ó»º´æÖлñÈ¡¡£
    • ÉèÖÃÏìӦͷ x-edgefunctions-cache Ϊ miss £¬±íʾÕâÊÇÒ»¸öδÃüÖлº´æµÄÇëÇó¡£
    • ·µ»ØԭʼÏìÓ¦¸øÇëÇóÕß¡£
  2. handleEvent º¯Êý£º
    • ¸Ãº¯ÊýÓÃÓÚ¼ì²éÇëÇóµÄURLÊÇ·ñÖ¸ÏòÒ»¸öͼƬ×ÊÔ´£¨Í¨¹ýÎļþÀ©Õ¹ÃûÅжϣ©¡£
    • Èç¹ûÇëÇóµÄ²»ÊÇͼƬ×ÊÔ´£¬½«·µ»ØÒ»¸ö´íÎóÏìÓ¦¡£
    • Èç¹ûÊÇͼƬ×ÊÔ´£¬³¢ÊÔ´Ó»º´æÖлñÈ¡ÇëÇóµÄ×ÊÔ´¡£
    • Èç¹û»º´æÖдæÔÚ×ÊÔ´£¬ÔòÉèÖÃÏìӦͷ x-edgefunctions-cache Ϊ hit £¬±íʾÕâÊÇÒ»¸öÃüÖлº´æµÄÇëÇ󣬲¢·µ»Ø»º´æÖеÄ×ÊÔ´¡£
    • Èç¹û»º´æÖв»´æÔÚ×ÊÔ´»ò·¢ÉúÒì³££¨È绺´æ¹ýÆÚ£©£¬Ôòɾ³ý»º´æ²¢ÖØе÷Óà fetchJquery º¯Êý»ñÈ¡×ÊÔ´¡£

ÔÚ·ÃÎÊͼƬ×ÊԴʱ£¬ÐèÒªÌرð×¢ÒâµÄÊÇ£¬ÎÒ²ÉÓÃÁË·¾¶ºóÃæµÄ IP ²ÎÊý½øÐзÃÎÊ¡£ÕâÊÇÒòΪ HAI ÿ´ÎÖØÆôºóÍâÍø IP ¶¼»á·¢Éú±ä»¯£¬Èç¹ûÿ´Î¶¼ÒªÐÞ¸Äÿ¸ö±ßÔµº¯ÊýµÄ»°£¬»áÏ൱·±Ëö¡£ÎªÁ˱ÜÃâÕâÖÖÇé¿ö£¬ÎÒÑ¡Ôñͨ¹ý²ÎÊý´«µÝµÄ·½Ê½À´»ñȡͼƬ×ÊÔ´¡£ÕâÑùÒ»À´£¬»ñȡͼƬ×ÊÔ´µÄ±ßÔµº¯Êý¾Í²»ÐèÒªÔÙ½øÐÐÈκÎÐÞ¸ÄÁË¡£ÁíÍ⣬Ä㻹ÐèÒª¶ÔÆ¥Åä´¥·¢¹æÔò½øÐÐÅäÖ㬱ÈÈçÎÒÉèÖõĹæÔòÊÇ°üº¬ "/images" µÄ·¾¶²Å»á´¥·¢ÏàÓ¦µÄ²Ù×÷¡£


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

ÔÚä¯ÀÀÆ÷ÖÐÊäÈëĬÈÏÓòÃû£¬²¢ËæÒâÌí¼Ó "/images/*.png" ¼´¿É·ÃÎÊÏàӦͼƬ£¬Ç°ÌáÊǸÃͼƬ´æ´¢ÓÚÎÒÃǵķþÎñÆ÷ÉÏ¡£ÏÖÔÚÈÃÎÒÃÇÀ´¹Û²ìÒ»ÏÂЧ¹û¡£ÖµµÃ×¢ÒâµÄÊÇ£¬ÕâÖÖ·½Ê½µÄÃüÖÐÂʲ¢²»ÊǺܸߣ¬ËùÒÔÔÚ¸Õ²¿ÊðÍê±ßÔµº¯Êýºó£¬ÐèÒª¶àˢм¸´Î²ÅÄÜ¿´µ½Ð§¹û¡£


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

¾²Ì¬ÍøÒ³

Õâ¸ö±ßÔµº¯ÊýרÃÅÓÃÓÚ´¦ÀíÓû§½»»¥¡£

const html = `



    
    
    AI��ͼ
    


    

��ͼ���

�ı�����

`; async function handleRequest(request) { return new Response(html, { headers: { 'content-type': 'text/html; charset=UTF-8', 'x-edgefunctions-test': 'Welcome to use Edge Functions.', }, }); } addEventListener('fetch', event => { event.respondWith(handleRequest(event.request)); });

��δ��붨����һ��HTMLҳ�棬����չʾһ��AI��ͼӦ�õ��û����棬����������֮������JavaScript���롣��Ҫ���ܺ���ɲ������£�

  1. HTML�ṹ ��
    • ҳ�����һ������ container �����ڲ���������Ҫ���֣���ͼ���չʾ���ı��������롣
    • ��ͼ������ְ���һ�������һ��ͼ������ image-container ������չʾAI���ɵ�ͼ��
    • �ı��������ְ��������ı����� text-description �� text-description2 �����û��������������ͷ�������������ָ��AI��ͼ��
    • һ����ť generate-button �����ڴ���AI��ͼ���̡�
  2. JavaScript�߼� ��
    • ҳ�������ɺ󣬵��� createImageList ��������̬����һ��ͼƬ�б���չʾ��ҳ���ϡ�
    • ���� generate-button ��ť�ĵ���¼����ռ��û������������ѡ��IJ���������һ��AI��ͼ���󣬲����͵���������
    • ʹ�� XMLHttpRequest ������POST����ָ���ķ�������ַ��������Ӧ����̬����ҳ���ϵ�ͼ��������չʾ���ɵ�ͼ��

���ǿ�һ������Ч����


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

���Ѿ��� IP ��ַ���������������ȷ����С���䶯���������Ҫ������ֻ����� IP ��ַ��Ȼ�����²��𼴿����·��ʡ�


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

�������ٴι۲�һ������ͼƬ��Ч�����������ʱ����̨�ӿڵ���ӦҲ���������ġ�


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤


  EdgeOne£ºÈ«Çò¼ÓËÙÓ밲ȫ·À»¤

����ȷʵ���������ռ䣬����ϸ�����һ�£�����������ܳ���ģ�͵������ϡ����磬���ڿ��߱Ȳ����������ε�ͼ�񣬿�����΢��һ����һ�㡣�������ɵ�ͼ�����߹����ԡ�����Щ���ⶼ�ǿ���ͨ�����Խ���ġ��ܵ���˵�����ǵ�EdgeOne��HAI���λ������Ѿ�ȡ���˽׶��Եijɹ������Ǹ�һ�����ˡ�

�ܽ�

��ƪ����Դ�����˴��������������˼������Ͷ���˴���ʱ���뾫����������EdgeOne��HAI֮���Эͬ���ԣ��˷����ڶ༼���������⡣ͨ����и��Ŭ�����ɹ��ؽ�������ǿ���ƽ̨������һ�𣬴����һ���������IJο����������̽��Ҳ���Ҹ����״������Ե����ʽ��Ʒ��ʵ��֮�á���ϣ��ͨ��������εľ����ͳɹ����ܹ����������˶���Щǰ�ؼ�������Ȥ��̽�����������ҵ���Ŀ����Ȥ�����ߴ��л����������������������֧�֣�Ҳ��ӭ��ע�ң�һ����ѧϰ����ͬ������

Edge2.2.0
Edge2.2.0
δ֪ ï¿½ï¿½È«ï¿½Þ¹ï¿½ï¿½
��(0)  04.09 ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½
�Ƽ�

���º�������

����

���η��ư�

����

��Ѷ�Ķ�

����


��ICP��2022002427��-10 �湫��������43070202000427��
© 2013~2024 haote.com ������