{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-@l10n/vi/sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"type":"markdown"},"seo":{"title":"Triển khai máy chủ Linux","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"triển-khai-máy-chủ-linux","__idx":0},"children":["Triển khai máy chủ Linux"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Triển khai MoreLogin trên máy chủ Ubuntu không đầu và tự động hóa cấu hình trình duyệt thông qua API cục bộ - không cần môi trường máy tính để bàn."]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"những-gì-bạn-sẽ-đạt-được","__idx":1},"children":["Những gì bạn sẽ đạt được"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Đến cuối hướng dẫn này, bạn sẽ có:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Một phiên bản MoreLogin đang chạy trên máy chủ không đầu Ubuntu 24.04"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Chuyển tiếp mạng được định cấu hình để các máy bên ngoài có thể kết nối qua CDP (Giao thức Chrome DevTools)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Tập lệnh tự động hóa Python đang hoạt động để tạo, khởi chạy, điều khiển và dọn dẹp cấu hình trình duyệt"]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"tổng-quan-về-kiến-trúc","__idx":2},"children":["Tổng quan về kiến trúc"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"┌──────────────────────────────────────────────────────────┐\n│                    Ubuntu 24.04 Server                   │\n│                                                          │\n│  ┌──────────────┐    ┌───────────────────────────────┐   │\n│  │   xvfb       │───▶│  MoreLogin AppImage           │   │\n│  │ (virtual     │    │  Local API :40000             │   │\n│  │  display)    │    │  CDP debug :<dynamic>         │   │\n│  │              │    │    (127.0.0.1, per profile)   │   │\n│  └──────────────┘    └───────────────────────────────┘   │\n│                              │                           │\n│                        socat forwarding                  │\n│                              │                           │\n│                     0.0.0.0:40001 → 127.0.0.1:40000      │\n│                     0.0.0.0:<N+1> → 127.0.0.1:<N>        │\n└──────────────────────────────────────────────────────────┘\n                               │\n                          External machine\n                     (Playwright / Puppeteer / Selenium)\n"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!NOTE]"," ","Cổng gỡ lỗi CDP ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["động"]}," — mỗi cấu hình trình duyệt có cổng riêng, được trả về bởi điểm cuối ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/env/start"]},". Sơ đồ trên sử dụng ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["<N>"]}," làm phần giữ chỗ."]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"điều-kiện-tiên-quyết","__idx":3},"children":["Điều kiện tiên quyết"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Yêu cầu"},"children":["Yêu cầu"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Chi tiết"},"children":["Chi tiết"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Hệ điều hành"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Máy chủ Ubuntu 24.04 (x86_64)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Thông số kỹ thuật được đề xuất"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["8 vCPU, RAM 8 GB (hỗ trợ ~5 cấu hình đồng thời)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Mạng"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Truy cập internet bên ngoài; mở cổng vào ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["40001"]}," và các cổng CDP được chuyển tiếp mà bạn chọn hoặc thay vào đó hãy sử dụng đường hầm SSH"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Python"]}," (tùy chọn)"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Python 3.8+ với ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["pip"]}," để chạy tập lệnh mẫu"]}]}]}]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"bước-1---cài-đặt-phụ-thuộc-hệ-thống","__idx":4},"children":["Bước 1 - Cài đặt phụ thuộc hệ thống"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Kết nối với máy chủ của bạn thông qua SSH và cài đặt các gói cần thiết:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# FUSE support (required for AppImage)\nsudo apt install -y libfuse2t64\n\n# GTK / accessibility / display libraries\nsudo apt install -y libatk1.0-0 libatk-bridge2.0-0 libatspi2.0-0\nsudo apt install -y libcups2\nsudo apt install -y libgtk-3-0 libgdk-pixbuf2.0-0\nsudo apt install -y libgbm1 libxkbcommon0 libasound2t64\n\n# Virtual framebuffer (headless display)\nsudo apt install -y xvfb\n\n# TCP forwarder\nsudo apt install -y socat\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"cài-đặt-phông-chữ-tùy-chọn","__idx":5},"children":["Cài đặt phông chữ (Tùy chọn)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Nếu các trang trình duyệt hiển thị không có văn bản hoặc hiển thị các ký tự bị thiếu, hãy cài đặt các gói phông chữ tương ứng:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# CJK (Chinese, Japanese, Korean)\nsudo apt install -y fonts-noto-cjk fonts-noto-cjk-extra\n\n# Arabic\nsudo apt install -y fonts-noto-color-emoji fonts-noto-extra\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Đối với các ngôn ngữ khác, hãy cài đặt gói ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://fonts.google.com/noto"},"children":["Họ phông chữ Noto"]}," phù hợp."]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"bước-2---tải-xuống-và-khởi-chạy-thêmđăng-nhập","__idx":6},"children":["Bước 2 - Tải xuống và khởi chạy ThêmĐăng nhập"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"21-tải-xuống-hình-ảnh-ứng-dụng","__idx":7},"children":["2.1 Tải xuống hình ảnh ứng dụng"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"wget https://get.morelogin.com/client/prod/linux/x64/2.54.0/MoreLogin_x86_64_2.54.0.AppImage\nchmod +x MoreLogin_x86_64_2.54.0.AppImage\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Thay thế ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["2.54.0"]}," bằng phiên bản mới nhất có sẵn từ tài khoản MoreLogin của bạn hoặc ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.morelogin.com/download/"},"children":["trang tải xuống"]},"."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"22-bắt-đầu-thêmđăng-nhập-trong-nền","__idx":8},"children":["2.2 Bắt đầu thêmĐăng nhập trong nền"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Sử dụng ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["xvfb-run"]}," để cung cấp màn hình ảo, sau đó chạy AppImage:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"nohup xvfb-run -a ./MoreLogin_x86_64_2.54.0.AppImage --no-sandbox > morelogin.log 2>&1 &\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Xác minh nó đã bắt đầu thành công:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# Check the process is running\nps aux | grep MoreLogin\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Quá trình này có thể mất 5–10 giây để khởi tạo hoàn toàn."]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"bước-3---đăng-nhập-vào-morelogin-qua-api-bắt-buộc","__idx":9},"children":["Bước 3 - Đăng nhập vào MoreLogin qua API (Bắt buộc)"]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!CAUTION]"," ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Bạn phải đăng nhập trước khi gọi bất kỳ điểm cuối API cục bộ nào khác."]}," Trên máy chủ không đầu không có GUI để đăng nhập theo cách thủ công, vì vậy bạn phải xác thực qua API. Nếu không có bước này, tất cả lệnh gọi API sẽ trả về:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\"status\": \"error\", \"code\": 401, \"message\": \"Trạng thái đăng nhập của bạn đã hết hạn, vui lòng đăng nhập lại\"}\n","lang":"json"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"31-nhận-thông-tin-xác-thực-api-của-bạn","__idx":10},"children":["3.1 Nhận thông tin xác thực API của bạn"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Mở ứng dụng khách máy tính để bàn MoreLogin (trên bất kỳ máy nào bạn đã đăng nhập) và điều hướng đến ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Cài đặt → API & MCP"]},". Sao chép ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["ID ỨNG DỤNG"]}," và ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Khóa API"]}," từ phần ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Mở API"]},":"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"img","attributes":{"src":"/assets/image.cfac9a4c31ae47e8434739e42cab4601ee08d737bba4fccba40f2f3bc78e9648.35e5403d.png","alt":"Cài đặt API đăng nhập nhiều hơn — Sao chép ID ứng dụng và khóa API từ phần API mở"},"children":[]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"32-đăng-nhập-qua-cuộn-tròn","__idx":11},"children":["3.2 Đăng nhập qua cuộn tròn"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Gọi điểm cuối đăng nhập bằng thông tin đăng nhập của bạn:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -X POST http://127.0.0.1:40000/api/user/login \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"apiId\": \"YOUR_APP_ID\",\n    \"apiKey\": \"YOUR_API_KEY\"\n  }'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Một phản hồi thành công trông giống như:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\"code\": 0, \"msg\": null, \"data\": true}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"33-xác-minh-thông-tin-đăng-nhập","__idx":12},"children":["3.3 Xác minh thông tin đăng nhập"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Xác nhận API đã sẵn sàng bằng cách liệt kê hồ sơ trình duyệt:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -s -X POST http://127.0.0.1:40000/api/env/page \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"pageNo\": 1, \"pageSize\": 1}'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Phản hồi ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["{\"code\":0, ...}"]}," có nghĩa là bạn đã đăng nhập và API đã sẵn sàng."]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Điểm kiểm tra:"]}," Máy chủ MoreLogin của bạn đã hoạt động đầy đủ. Hãy tiếp tục tới ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#step-4--configure-network-forwarding-socat"},"children":["Bước 4"]}," để truy cập từ xa hoặc chuyển thẳng tới ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#step-5--quick-automation-example"},"children":["Bước 5"]}," nếu chạy tập lệnh trên cùng một máy chủ."]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!NOTE]"," ","Phiên đăng nhập vẫn tiếp tục miễn là quá trình MoreLogin đang chạy. Nếu khởi động lại AppImage, bạn sẽ cần phải đăng nhập lại."]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"bước-4---định-cấu-hình-chuyển-tiếp-mạng-socat","__idx":13},"children":["Bước 4 - Định cấu hình Chuyển tiếp mạng (socat)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Theo mặc định, cả cổng gỡ lỗi API cục bộ (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[":40000"]},") và CDP đều liên kết với ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["127.0.0.1"]},". Nếu bạn cần truy cập chúng từ máy bên ngoài (ví dụ: máy tính xách tay phát triển của bạn), hãy sử dụng ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["socat"]}," để chuyển tiếp lưu lượng truy cập."]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!WARNING]"," ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Rủi ro bảo mật — không để các cổng này tiếp xúc với Internet công cộng."]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["API cục bộ ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["không có tính năng xác thực tích hợp"]}," cho hầu hết các điểm cuối."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Cổng gỡ lỗi CDP cấp ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["toàn quyền điều khiển từ xa"]}," phiên bản trình duyệt (đọc cookie, chèn tập lệnh, chụp ảnh màn hình)."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Khuyến nghị:"]}]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Sử dụng ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["đường hầm SSH"]}," thay vì socat để truy cập từ xa: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ssh -L 40000:127.0.0.1:40000 user@server"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Nếu bạn phải sử dụng socat, hãy hạn chế quyền truy cập bằng quy tắc tường lửa đối với ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["chỉ các IP cụ thể"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Sử dụng ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["VPN"]}," hoặc nhóm bảo mật của nhà cung cấp dịch vụ đám mây để hạn chế lưu lượng truy cập vào"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Không bao giờ"]}," mở cổng ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["40001"]}," / CDP tới ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["0.0.0.0"]}," trên máy chủ công khai mà không có giới hạn IP"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"41-chuyển-tiếp-cổng-api-cục-bộ","__idx":14},"children":["4.1 Chuyển tiếp cổng API cục bộ"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"nohup socat TCP-LISTEN:40001,fork,reuseaddr,bind=0.0.0.0 TCP:127.0.0.1:40000 &\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Máy bên ngoài hiện có thể tiếp cận API tại ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["http://<server-ip>:40001"]},"."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"42-chuyển-tiếp-cổng-gỡ-lỗi-cdp","__idx":15},"children":["4.2 Chuyển tiếp cổng gỡ lỗi CDP"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Khi bạn khởi động cấu hình trình duyệt qua API, phản hồi sẽ bao gồm ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["động"]}," ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["debugPort"]}," (ví dụ: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["9222"]},"). Mỗi hồ sơ có thể nhận được một cổng khác nhau. Chuyển tiếp nó để các công cụ tự động hóa bên ngoài (Playwright, Puppeteer, Selenium) có thể kết nối:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# Example: if debugPort=9222, forward to external port 9223 (debugPort + 1)\n# Adjust both ports to match the actual debugPort returned by /api/env/start\nnohup socat TCP-LISTEN:9223,fork,reuseaddr,bind=0.0.0.0 TCP:127.0.0.1:9222 &\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!WARNING]"," ","Khi chạy đồng thời nhiều cấu hình, hãy đảm bảo các cổng chuyển tiếp không xung đột với các cổng gỡ lỗi của cấu hình khác. Ví dụ: nếu cấu hình A nhận được ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["debugPort=9222"]}," và bạn chuyển tiếp tới ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["9223"]}," nhưng cấu hình B nhận được ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["debugPort=9223"]}," thì sẽ xảy ra xung đột cổng. Hãy cân nhắc sử dụng khoảng chênh lệch lớn hơn hoặc phạm vi cổng chuyên dụng."]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!TIP]"," ","Trong quá trình sản xuất, hãy tạo chuyển tiếp socat ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["động"]}," sau mỗi cuộc gọi ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/env/start"]},", sử dụng ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["debugPort"]}," được trả về. Xem ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#52-create--start--automate--cleanup"},"children":["ví dụ về Python"]}," để biết cách triển khai hoạt động."]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Nếu chạy tập lệnh tự động hóa ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["trên cùng một máy chủ"]},", bạn có thể bỏ qua socat và kết nối trực tiếp với ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["127.0.0.1"]},"."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"43-mở-cổng-tường-lửa","__idx":16},"children":["4.3 Mở cổng tường lửa"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Nếu bạn sử dụng socat, chỉ hạn chế quyền truy cập vào các IP đáng tin cậy:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# Allow only a specific IP (recommended)\nsudo ufw allow from <YOUR_IP> to any port 40001 proto tcp\nsudo ufw allow from <YOUR_IP> to any port 9223 proto tcp\n\n# Or allow from any IP (NOT recommended for production)\n# sudo ufw allow 40001/tcp\n# sudo ufw allow 9223/tcp\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"44-khuyến-nghị-thay-vào-đó-hãy-sử-dụng-đường-hầm-ssh","__idx":17},"children":["4.4 Khuyến nghị: Thay vào đó hãy sử dụng Đường hầm SSH"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Để truy cập từ xa an toàn nhất, hãy sử dụng đường hầm SSH — không cần thay đổi tường lửa hoặc socat."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Vì cổng CDP là ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["động"]}," (được chỉ định khi bạn khởi động cấu hình) nên quy trình làm việc là:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Trước tiên hãy đào cổng API:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# Run this on your local machine\nssh -L 40000:127.0.0.1:40000 user@<server-ip>\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Bắt đầu cấu hình"]}," qua API được tạo đường hầm (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["http://127.0.0.1:40000/api/env/start"]},") và đọc ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["debugPort"]}," được trả về."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Mở đường hầm thứ hai cho cổng CDP:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"# Replace <debugPort> with the actual port returned by the API\nssh -L <debugPort>:127.0.0.1:<debugPort> user@<server-ip>\n","lang":"bash"},"children":[]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Kết nối"]}," với ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["http://127.0.0.1:<debugPort>"]}," từ tập lệnh Nhà viết kịch / Người múa rối cục bộ của bạn như thể máy chủ là cục bộ."]}]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!TIP]"," ","Bạn có thể kết hợp cả hai đường hầm trong một lệnh nếu bạn biết trước phạm vi cổng, ví dụ:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"ssh -L 40000:127.0.0.1:40000 -L 9222:127.0.0.1:9222 -L 9223:127.0.0.1:9223 user@<server-ip>\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Nhưng trên thực tế, việc khởi động đường hầm API trước sẽ dễ dàng hơn, sau đó thêm đường hầm theo từng cấu hình nếu cần."]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"bước-5---ví-dụ-về-tự-động-hóa-nhanh","__idx":18},"children":["Bước 5 - Ví dụ về tự động hóa nhanh"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Dưới đây là ví dụ Python tối thiểu hiển thị toàn bộ vòng đời của cấu hình trình duyệt. Để biết tập lệnh hoàn chỉnh sẵn sàng sản xuất có tính năng xử lý đồng thời và lỗi, hãy xem ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/MoreLoginBrowser/MoreLogin-API-Demos/blob/main/MoreLogin-Python/linux_server_test.py"},"children":["ví dụ đầy đủ trên GitHub"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"51-cài-đặt-phụ-thuộc-python","__idx":19},"children":["5.1 Cài đặt phụ thuộc Python"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"pip install requests playwright\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Nhà viết kịch chỉ được sử dụng ở đây cho ứng dụng khách CDP (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["connect_over_cdp"]},"). Bạn ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["không"]}," cần chạy ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["playwright install"]}," — MoreLogin cung cấp trình duyệt riêng."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"52-đặt---no-sandbox-cho-hồ-sơ-trình-duyệt-bắt-buộc-trên-linux","__idx":20},"children":["5.2 Đặt ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--no-sandbox"]}," cho Hồ sơ Trình duyệt (Bắt buộc trên Linux)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Trên Linux Server, trình duyệt ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["phải"]}," chạy với cờ ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--no-sandbox"]},". Bạn truyền tham số này qua trường ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["startupParams"]}," khi tạo hoặc cập nhật hồ sơ trình duyệt."]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!CAUTION]"," ","Nếu thiếu ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--no-sandbox"]},", trình duyệt sẽ không thể khởi chạy trên hầu hết các môi trường Linux server (đặc biệt khi chạy với quyền ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["root"]}," hoặc thiếu phiên desktop đầy đủ)."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"hồ-sơ-mới--bao-gồm-startupparams-khi-tạo","__idx":21},"children":["Hồ sơ mới — bao gồm ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["startupParams"]}," khi tạo"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Sử dụng ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/env/create/advanced"]}," để tạo hồ sơ có ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["startupParams"]}," (endpoint ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/env/create/quick"]}," ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["không hỗ trợ"]}," trường này):"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -X POST http://127.0.0.1:40000/api/env/create/advanced \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"browserTypeId\": 1,\n    \"operatorSystemId\": 5,\n    \"startupParams\": [\"--no-sandbox\"]\n  }'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!TIP]"," ","Nếu bạn đã dùng ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/env/create/quick"]}," để tạo hồ sơ, hãy gọi ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/env/update"]}," để thêm ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--no-sandbox"]}," trước khi khởi chạy — xem bên dưới."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"hồ-sơ-hiện-có--cập-nhật-qua-apienvupdate","__idx":22},"children":["Hồ sơ hiện có — cập nhật qua ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/env/update"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Nếu bạn đã có hồ sơ trình duyệt được tạo mà không có ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--no-sandbox"]},", hãy cập nhật trước khi khởi chạy:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"curl -X POST http://127.0.0.1:40000/api/env/update \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"envId\": \"YOUR_ENV_ID\",\n    \"startupParams\": [\"--no-sandbox\"]\n  }'\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!NOTE]"," ","Trường ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["startupParams"]}," chấp nhận một mảng chuỗi. Bạn cũng có thể thêm các cờ Chrome khác (ví dụ: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["[\"--no-sandbox\", \"--disable-gpu\"]"]},"). Cờ ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--no-sandbox"]}," chỉ cần thiết trên Linux — các hồ sơ Windows và macOS không cần."]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"53-tạo--bắt-đầu--tự-động-hóa--dọn-dẹp","__idx":23},"children":["5.3 Tạo → Bắt đầu → Tự động hóa → Dọn dẹp"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Ví dụ này giả định tập lệnh chạy ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["trên cùng một máy chủ"]}," với MoreLogin. Đối với các kịch bản từ xa, hãy xem ghi chú sau mã."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import requests\nfrom playwright.sync_api import sync_playwright\n\n# ── Configuration ──────────────────────────────────────────\n# Local:  script runs on the SAME server as MoreLogin\n# Remote: script runs on a DIFFERENT machine — see notes below\nAPI_BASE  = \"http://127.0.0.1:40000\"\n\n\n# ① Create a browser profile\nresp = requests.post(f\"{API_BASE}/api/env/create/quick\", json={\n    \"browserTypeId\": 1,\n    \"operatorSystemId\": 5,\n    \"quantity\": 1\n})\nresp_data = resp.json()\nassert resp_data[\"code\"] == 0, f\"Create failed: {resp_data}\"\nenv_id = resp_data[\"data\"][\"envIds\"][0]\nprint(f\"✅ Created profile: {env_id}\")\n\n\n# ①-b Add --no-sandbox (required on Linux Server)\nresp = requests.post(f\"{API_BASE}/api/env/update\", json={\n    \"envId\": env_id,\n    \"startupParams\": [\"--no-sandbox\"]\n})\nresp_data = resp.json()\nassert resp_data[\"code\"] == 0, f\"Update failed: {resp_data}\"\nprint(f\"✅ Set --no-sandbox for profile: {env_id}\")\n\n\n# ② Start the profile (headless)\nresp = requests.post(f\"{API_BASE}/api/env/start\", json={\n    \"envId\": env_id\n})\nresp_data = resp.json()\nassert resp_data[\"code\"] == 0, f\"Start failed: {resp_data}\"\ndebug_port = resp_data[\"data\"][\"debugPort\"]   # Dynamic — different for each profile\nprint(f\"✅ Started — debug port: {debug_port}\")\n\n\n# ③ Build the CDP URL\ncdp_url = f\"http://127.0.0.1:{debug_port}\"\n\n\n# ④ Connect via CDP and automate\nwith sync_playwright() as p:\n    browser = p.chromium.connect_over_cdp(cdp_url)\n    page = browser.contexts[0].pages[0]\n    page.goto(\"https://www.google.com\")\n    page.screenshot(path=f\"screenshot_{env_id}.png\")\n    print(f\"✅ Screenshot saved\")\n    # Use disconnect() — not close() — to detach without killing the browser.\n    # The profile will be stopped cleanly via the API in step ⑤.\n    browser.disconnect()\n\n\n# ⑤ Stop the profile\nrequests.post(f\"{API_BASE}/api/env/close\", json={\"envId\": env_id})\nprint(f\"✅ Profile stopped\")\n\n\n# ⑥ Delete the profile\nrequests.post(f\"{API_BASE}/api/env/remove\", json={\"envIds\": [env_id]})\nprint(f\"✅ Profile deleted\")\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!NOTE]"," ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Chạy từ máy từ xa?"]}," Hai cách tiếp cận:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Tùy chọn A — Đường hầm SSH (được khuyến nghị):"]}," ","Thiết lập đường hầm SSH từ máy cục bộ của bạn đến máy chủ (xem ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#44-recommended-use-ssh-tunnel-instead"},"children":["§ 4.4"]},"), sau đó giữ ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["API_BASE = \"http://127.0.0.1:40000\""]}," và ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cdp_url = f\"http://127.0.0.1:{debug_port}\""]}," — SSH làm cho các cổng từ xa xuất hiện cục bộ."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Tùy chọn B — socat trên máy chủ:"]}," ","Trên ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["máy chủ"]},", bắt đầu chuyển tiếp socat cho cổng API và cho mỗi cổng CDP:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"# Chạy chúng trên MÁY CHỦ, không phải trên máy cục bộ của bạn\nsocat TCP-LISTEN:40001,fork,reuseaddr,bind=0.0.0.0 TCP:127.0.0.1:40000 &\nsocat TCP-LISTEN:$((debug_port+1)),fork,reuseaddr,bind=0.0.0.0 TCP:127.0.0.1:$debug_port &\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Sau đó, trong tập lệnh của bạn, hãy đặt ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["API_BASE = \"http://<server-ip>:40001\""]}," và ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cdp_url = f\"http://<server-ip>:{debug_port + 1}\""]},"."," ","⚠️ Hạn chế quyền truy cập bằng quy tắc tường lửa — xem ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#43-open-firewall-ports"},"children":["§ 4.3"]},"."]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!IMPORTANT]"," ","Cấu trúc ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["resp.json()[\"data\"][\"envIds\"]"]}," khớp với định dạng phản hồi ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/env/create/quick"]}," hiện tại. Nếu bạn gặp một hình dạng khác (ví dụ: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["data: [\"id1\", ...]"]},"), hãy kiểm tra ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/vi/api-reference/browser"},"children":["Tham khảo API"]}," cho phiên bản của bạn — định dạng phản hồi có thể khác nhau giữa các bản phát hành."]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"điểm-chuẩn-hiệu-suất","__idx":24},"children":["Điểm chuẩn hiệu suất"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Các kết quả sau đây thu được trên máy ảo Ubuntu 24.04 Server (8 vCPU, 8 GB RAM) bằng cách sử dụng ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/MoreLoginBrowser/MoreLogin-API-Demos/blob/main/MoreLogin-Python/linux_server_test.py"},"children":["tập lệnh kiểm tra mức độ căng thẳng đầy đủ"]},":"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Số liệu"},"children":["Số liệu"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Giá trị"},"children":["Giá trị"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Tổng số lượt chạy"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["100"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Đồng thời"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["4 (đồng thời)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Tỷ lệ thành công"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["100,0%"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Tổng thời gian"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["604,06 giây"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Thời gian trung bình cho mỗi nhiệm vụ"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["6,04 giây"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Thông lượng"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["0,17 nhiệm vụ/giây"]}]}]}]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Những con số này phục vụ như là một đường cơ sở. Hiệu suất thực tế phụ thuộc vào thông số kỹ thuật của máy chủ, điều kiện mạng và độ phức tạp của trang."]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"triển-khai-sản-xuất-systemd","__idx":25},"children":["Triển khai sản xuất (systemd)"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Đối với các máy chủ sản xuất, hãy chạy MoreLogin dưới dạng ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["dịch vụ systemd"]}," để tự động khởi động khi khởi động, khởi động lại khi gặp sự cố và ghi nhật ký tập trung."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"tạo-tệp-dịch-vụ","__idx":26},"children":["Tạo tệp dịch vụ"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"sudo tee /etc/systemd/system/morelogin.service > /dev/null <<'EOF'\n[Unit]\nDescription=MoreLogin Browser (headless)\nAfter=network-online.target\nWants=network-online.target\n\n[Service]\nType=simple\nUser=root\nWorkingDirectory=/opt/morelogin\nExecStart=/usr/bin/xvfb-run -a /opt/morelogin/MoreLogin_x86_64_2.54.0.AppImage --no-sandbox\nRestart=on-failure\nRestartSec=10\nStandardOutput=journal\nStandardError=journal\n\n[Install]\nWantedBy=multi-user.target\nEOF\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Điều chỉnh đường dẫn ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["WorkingDirectory"]}," và ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ExecStart"]}," để khớp với vị trí bạn đã đặt AppImage."]}]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!TIP]"," ","Đối với sản xuất, hãy cân nhắc việc tạo người dùng chuyên dụng (ví dụ: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["morelogin"]},") thay vì chạy dưới dạng ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["root"]}," và điều chỉnh quyền sở hữu cũng như quyền đối với tệp cho phù hợp. Nếu AppImage hiện yêu cầu đặc quyền root thì bạn có thể giữ ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["User=root"]}," nhưng cách ly quy trình trong tài khoản không phải root là cách tốt nhất."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"kích-hoạt-và-bắt-đầu","__idx":27},"children":["Kích hoạt và bắt đầu"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"sudo systemctl daemon-reload\nsudo systemctl enable morelogin    # Auto-start on boot\nsudo systemctl start morelogin     # Start now\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"quản-lý-dịch-vụ","__idx":28},"children":["Quản lý dịch vụ"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"sudo systemctl status morelogin    # Check status\nsudo journalctl -u morelogin -f    # Stream logs\nsudo systemctl restart morelogin   # Restart\nsudo systemctl stop morelogin      # Stop\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"blockquote","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["[!NOTE]"," ","Sau khi khởi động lại, bạn phải gọi lại ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#32-log-in-via-curl"},"children":["điểm cuối đăng nhập"]}," — phiên API không tồn tại trong quá trình khởi động lại. Để khôi phục tự động, hãy cân nhắc thêm tập lệnh ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ExecStartPost"]}," hoặc công việc định kỳ kiểm tra tình trạng gọi điểm cuối đăng nhập sau khi dịch vụ khởi động."]}]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"khắc-phục-sự-cố","__idx":29},"children":["Khắc phục sự cố"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"thêmđăng-nhập-không-khởi-động-được","__idx":30},"children":["ThêmĐăng nhập không khởi động được"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"AppImages require FUSE to run.\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Khắc phục:"]}," Cài đặt hỗ trợ FUSE:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"sudo apt install -y libfuse2t64\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"các-trang-trình-duyệt-hiển-thị-văn-bản-trốngký-tự-bị-thiếu","__idx":31},"children":["Các trang trình duyệt hiển thị văn bản trống/ký tự bị thiếu"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Khắc phục:"]}," Cài đặt gói phông chữ cho ngôn ngữ đích (xem ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#install-fonts-optional"},"children":["Bước 1 — Cài đặt phông chữ"]},")."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"kết-nối-cdp-bị-từ-chối-từ-máy-bên-ngoài","__idx":32},"children":["Kết nối CDP bị từ chối từ máy bên ngoài"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Lý do:"]}," Cổng gỡ lỗi CDP liên kết với ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["127.0.0.1"]}," theo mặc định."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Khắc phục:"]}," Thiết lập chuyển tiếp socat (xem ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#step-4--configure-network-forwarding-socat"},"children":["Bước 4"]},") và đảm bảo quy tắc tường lửa cho phép cổng chuyển tiếp."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"curl-tới-api-cục-bộ-trả-về-kết-nối-bị-từ-chối","__idx":33},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["curl"]}," tới API cục bộ trả về \"Kết nối bị từ chối\""]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Lý do:"]}," MoreLogin chưa khởi động xong hoặc quá trình bị lỗi."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Sửa chữa:"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Đợi 5–10 giây sau khi khởi động"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Kiểm tra ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["morelogin.log"]}," để tìm lỗi"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Xác minh quy trình đang chạy: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["ps aux | grep MoreLogin"]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"api-trả-về-401-trạng-thái-đăng-nhập-đã-hết-hạn","__idx":34},"children":["API trả về 401 \"trạng thái đăng nhập đã hết hạn\""]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"json","header":{"controls":{"copy":{}}},"source":"{\"status\": \"error\", \"code\": 401, \"message\": \"Your login status has expired, please log in again\"}\n","lang":"json"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Lý do:"]}," Bạn chưa đăng nhập qua API hoặc quá trình MoreLogin đã được khởi động lại."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Khắc phục:"]}," Gọi điểm cuối đăng nhập trước bất kỳ lệnh gọi API nào khác (xem ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#step-3--log-in-to-morelogin-via-api-required"},"children":["Bước 3"]},")."]},{"$$mdtype":"Tag","name":"hr","attributes":{},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"các-bước-tiếp-theo","__idx":35},"children":["Các bước tiếp theo"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Mục tiêu"},"children":["Mục tiêu"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"liên kết"},"children":["liên kết"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Tài liệu tham khảo API trình duyệt đầy đủ"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/vi/api-reference/browser"},"children":["API trình duyệt"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Thiết lập xác thực"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/vi/api-reference/getting-started/authentication"},"children":["Hướng dẫn xác thực"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Ví dụ về nhà viết kịch / Selenium / Puppeteer"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/vi/api-reference/examples"},"children":["Ví dụ về tự động hóa"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Hoàn thành tập lệnh kiểm tra căng thẳng Linux"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/MoreLoginBrowser/MoreLogin-API-Demos/blob/main/MoreLogin-Python/linux_server_test.py"},"children":["GitHub — linux_server_test.py"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["CLI bắt đầu nhanh"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/vi/cli/quick-start"},"children":["Hướng dẫn CLI"]}]}]}]}]}]}]},"headings":[{"value":"Triển khai máy chủ Linux","id":"triển-khai-máy-chủ-linux","depth":1},{"value":"Những gì bạn sẽ đạt được","id":"những-gì-bạn-sẽ-đạt-được","depth":2},{"value":"Tổng quan về kiến trúc","id":"tổng-quan-về-kiến-trúc","depth":2},{"value":"Điều kiện tiên quyết","id":"điều-kiện-tiên-quyết","depth":2},{"value":"Bước 1 - Cài đặt phụ thuộc hệ thống","id":"bước-1---cài-đặt-phụ-thuộc-hệ-thống","depth":2},{"value":"Cài đặt phông chữ (Tùy chọn)","id":"cài-đặt-phông-chữ-tùy-chọn","depth":3},{"value":"Bước 2 - Tải xuống và khởi chạy ThêmĐăng nhập","id":"bước-2---tải-xuống-và-khởi-chạy-thêmđăng-nhập","depth":2},{"value":"2.1 Tải xuống hình ảnh ứng dụng","id":"21-tải-xuống-hình-ảnh-ứng-dụng","depth":3},{"value":"2.2 Bắt đầu thêmĐăng nhập trong nền","id":"22-bắt-đầu-thêmđăng-nhập-trong-nền","depth":3},{"value":"Bước 3 - Đăng nhập vào MoreLogin qua API (Bắt buộc)","id":"bước-3---đăng-nhập-vào-morelogin-qua-api-bắt-buộc","depth":2},{"value":"3.1 Nhận thông tin xác thực API của bạn","id":"31-nhận-thông-tin-xác-thực-api-của-bạn","depth":3},{"value":"3.2 Đăng nhập qua cuộn tròn","id":"32-đăng-nhập-qua-cuộn-tròn","depth":3},{"value":"3.3 Xác minh thông tin đăng nhập","id":"33-xác-minh-thông-tin-đăng-nhập","depth":3},{"value":"Bước 4 - Định cấu hình Chuyển tiếp mạng (socat)","id":"bước-4---định-cấu-hình-chuyển-tiếp-mạng-socat","depth":2},{"value":"4.1 Chuyển tiếp cổng API cục bộ","id":"41-chuyển-tiếp-cổng-api-cục-bộ","depth":3},{"value":"4.2 Chuyển tiếp cổng gỡ lỗi CDP","id":"42-chuyển-tiếp-cổng-gỡ-lỗi-cdp","depth":3},{"value":"4.3 Mở cổng tường lửa","id":"43-mở-cổng-tường-lửa","depth":3},{"value":"4.4 Khuyến nghị: Thay vào đó hãy sử dụng Đường hầm SSH","id":"44-khuyến-nghị-thay-vào-đó-hãy-sử-dụng-đường-hầm-ssh","depth":3},{"value":"Bước 5 - Ví dụ về tự động hóa nhanh","id":"bước-5---ví-dụ-về-tự-động-hóa-nhanh","depth":2},{"value":"5.1 Cài đặt phụ thuộc Python","id":"51-cài-đặt-phụ-thuộc-python","depth":3},{"value":"5.2 Đặt --no-sandbox cho Hồ sơ Trình duyệt (Bắt buộc trên Linux)","id":"52-đặt---no-sandbox-cho-hồ-sơ-trình-duyệt-bắt-buộc-trên-linux","depth":3},{"value":"Hồ sơ mới — bao gồm startupParams khi tạo","id":"hồ-sơ-mới--bao-gồm-startupparams-khi-tạo","depth":4},{"value":"Hồ sơ hiện có — cập nhật qua /api/env/update","id":"hồ-sơ-hiện-có--cập-nhật-qua-apienvupdate","depth":4},{"value":"5.3 Tạo → Bắt đầu → Tự động hóa → Dọn dẹp","id":"53-tạo--bắt-đầu--tự-động-hóa--dọn-dẹp","depth":3},{"value":"Điểm chuẩn hiệu suất","id":"điểm-chuẩn-hiệu-suất","depth":2},{"value":"Triển khai sản xuất (systemd)","id":"triển-khai-sản-xuất-systemd","depth":2},{"value":"Tạo tệp dịch vụ","id":"tạo-tệp-dịch-vụ","depth":3},{"value":"Kích hoạt và bắt đầu","id":"kích-hoạt-và-bắt-đầu","depth":3},{"value":"Quản lý dịch vụ","id":"quản-lý-dịch-vụ","depth":3},{"value":"Khắc phục sự cố","id":"khắc-phục-sự-cố","depth":2},{"value":"ThêmĐăng nhập không khởi động được","id":"thêmđăng-nhập-không-khởi-động-được","depth":3},{"value":"Các trang trình duyệt hiển thị văn bản trống/ký tự bị thiếu","id":"các-trang-trình-duyệt-hiển-thị-văn-bản-trốngký-tự-bị-thiếu","depth":3},{"value":"Kết nối CDP bị từ chối từ máy bên ngoài","id":"kết-nối-cdp-bị-từ-chối-từ-máy-bên-ngoài","depth":3},{"value":"curl tới API cục bộ trả về \"Kết nối bị từ chối\"","id":"curl-tới-api-cục-bộ-trả-về-kết-nối-bị-từ-chối","depth":3},{"value":"API trả về 401 \"trạng thái đăng nhập đã hết hạn\"","id":"api-trả-về-401-trạng-thái-đăng-nhập-đã-hết-hạn","depth":3},{"value":"Các bước tiếp theo","id":"các-bước-tiếp-theo","depth":2}],"frontmatter":{"seo":{"title":"Triển khai máy chủ Linux"}},"lastModified":"2026-07-13T14:51:02.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/vi/linux-server/overview","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}