Bởi vì người dùng phải vào các vai trò máy chủ từ bên ngoài Nano, nên máy chủ sẽ có một bề mặt tấn công giảm nhiều khi so với GUI Windows Server.. Ứng dụng Docker chạy trong vùng chứa co
TỔNG QUAN VỀ ĐỀ TÀI
GIỚI THIỆU
Nano Server có kích thước cài đặt nhỏ hơn 92 phần trăm so với tùy chọn cài đặt GUI của Windows Server, giúp tiết kiệm tài nguyên và cải thiện hiệu suất; những lý do thuyết phục được trình bày sau đây cho thấy tại sao bạn có thể bắt đầu triển khai Nano cho các tải công việc Windows Server.
Hệ điều hành Bare-metal có nghĩa là người dùng ít cập nhật và khởi động lại, vì người dùng triển khai các vai trò máy chủ từ bên ngoài Nano, nên máy chủ có bề mặt tấn công giảm đáng kể so với GUI Windows Server Nano nhỏ đến mức có thể được chuyển dễ dàng giữa các máy chủ, trung tâm dữ liệu và các trang web vật lý Nano lưu trữ các khối lượng công việc Windows Server phổ biến nhất, bao gồm máy chủ Hyper-V Nano được thiết kế để quản lý hoàn toàn từ xa, tuy nhiên nó vẫn đi kèm với một giao diện quản lý cục bộ tối thiểu được gọi là "Nano Server Recovery Console" cho phép thực hiện các tác vụ cấu hình ban đầu.
Docker là nền tảng container giúp các nhà phát triển và quản trị hệ thống xây dựng, triển khai và vận hành ứng dụng một cách dễ dàng trên môi trường ảo hóa Với triết lý Build once, run anywhere, Docker đóng gói ứng dụng và phụ thuộc vào container, cho phép chạy trên bất kỳ hệ thống nào mà không ảnh hưởng đến môi trường hiện có của máy chủ hoặc máy tính cá nhân Ứng dụng chạy trong container được cô lập và độc lập với máy chủ, giúp triển khai nhất quán trên laptop của nhà phát triển, hạ tầng tại doanh nghiệp hay đám mây Docker có thể hoạt động trên Linux, Windows và macOS, mang lại tính di động và linh hoạt cho quá trình phát triển, tối ưu hóa CI/CD và vận hành ứng dụng.
IIS, viết tắt của Internet Information Services, là tập hợp các dịch vụ máy chủ tích hợp sẵn trên các phiên bản Windows hoặc có thể được cài đặt thêm, nhằm cung cấp chức năng cho máy chủ chạy trên Windows Nó giúp phân phối thông tin lên Internet bằng các dịch vụ như Web Server và FTP Server, đáp ứng nhu cầu lưu trữ, quản lý và trao đổi dữ liệu qua mạng Với IIS, bạn có thể triển khai và quản lý các ứng dụng web trên nền tảng Windows một cách hiệu quả.
FTP, viết tắt của File Transfer Protocol hay Giao thức truyền tập tin, là giao thức phổ biến để trao đổi tập tin qua các mạng dựa trên TCP/IP, như Internet (mạng ngoại bộ) hoặc Intranet (mạng nội bộ) Hoạt động của FTP yêu cầu hai máy tính tham gia: một máy chủ và một máy khách, cho phép truyền tải tập tin giữa các thiết bị một cách hiệu quả và có thể được quản lý truy cập tùy theo cấu hình.
Mỗi máy tính và thiết bị mạng tham gia mạng Internet đều giao tiếp với nhau bằng địa chỉ IP (Internet Protocol) Để thuận tiện cho việc sử dụng và dễ nhớ, ta dùng tên miền (domain name) để xác định thiết bị và tài nguyên trên Internet Hệ thống tên miền DNS (Domain Name System) đảm nhiệm việc ánh xạ giữa tên miền và địa chỉ IP, giúp người dùng có thể truy cập nhanh chóng bằng cách gõ tên miền thay vì phải nhớ địa chỉ IP.
(Domain Name System) được sử dụng để ánh xạ tên miền thành địa chỉ IP.
Vì vậy, khi liên hệ với các máy trên mạng, ta dùng tên miền dễ nhớ (domain name) như www.microsoft.com hoặc www.ibm.com thay vì phải nhớ một chuỗi địa chỉ IP dài và khó nhớ Tên miền đóng vai trò là địa chỉ dễ nhận diện cho người dùng và hệ thống định vị tài nguyên, giúp kết nối nhanh chóng và thuận tiện hơn mà không phải ghi nhớ từng địa chỉ số.
Ban đầu, trước khi DNS ra đời, các máy trong mạng lưu trữ thông tin về tên host và địa chỉ IP của từng máy trong một file có tên Host.txt đặt trên mỗi thiết bị để có thể truy cập các máy khác Khi có sự thay đổi về tên host hoặc địa chỉ IP, cần cập nhật toàn bộ các file Host.txt trên mọi máy, khiến quản lý mạng trở nên bất tiện Đến năm 1984, Paul Mockapetris thuộc Information Sciences Institute (USC) đã phát triển một hệ thống quản lý tên miền mới mang tên Domain Name System (DNS) nhằm thay thế Host.txt và tối ưu việc tra cứu tên miền thành địa chỉ IP.
Thông qua tìm hiểu về tổng quan ở chương I, làm cơ sở đề xuất phân tích thiết kế hệ thống sẽ được trình bày trong chương tiếp theo
PHÂN TÍCH THIẾT KẾ HỆ THỐNG
SƠ ĐỒ MẠNG
1 Sơ đồ mạng trên VMWare
2 Sơ đồ mạng trên google Engine
TRIỂN KHAI
TRIỂN KHAI TRÊN VMWare
- Sử dụng VyOS làm router, gồm có 3 network adapter o Network adapter (NAT) dùng để đi internet o Network adapter 2 (192.168.5.1) dùng cho phòng IT o Network apdater 3 (172.16.5.1) dung cho phòng kế toán
- Nanoserver được xem như là 1 server cục bộ
- Các chức năng đã triển khai trên nano server o Web Server (IIS) o DNS Server
To install Windows Nano Server on a real machine, mount the Windows Server 2016 ISO to a drive Since the drives of Windows Server 2016 are fixed when running on Hyper-V, you’ll need to install VMware’s dedicated drivers to ensure proper hardware support.
NanoServer o Mount file C:\Program Files (x86)\VMware\VMware
From your workstation, locate the Windows ISO and run setup.exe, or use the command prompt to execute /setup.exe /a; then copy the NanoServerImageGenerator folder you mounted from the Windows Server 2016 ISO to a new directory Finally, import that directory into PowerShell with Import-Module so you can access the NanoServerImageGenerator tools to create Nano Server images.
.\NanoServerImageGenerator.psd1 o Sủ dụng powershell hoặc windows terminal để chạy New-NanoServerImage -Edition Datacenter -MediaPath G:\ -BasePath \Base -TargetPath
Deploy Windows Nano Server from the VHDX by running NanoServerTest.vhdx with DeploymentType set to Guest and ComputerName NanoVM, and specify the Storage package: Microsoft-NanoServer-IIS-Package and Microsoft-NanoServer-DNS-Package, with DriverPath set to /VMWareTools/Drivers In this setup, TargetPath indicates where the Windows Nano Server image is stored, and MediaPath indicates the drive letter or path of the mounted Windows Server file.
2016 iso ra Package là các package mà mình cần cài vào Nano Server, ở đây đang cài IIS và DNS (vào ổ đĩa vừa mount > NanoServer > Packages để lấy tên Package
DrivePath is the path to the VMware-mounted drive folder After you obtain the VHDX file, you need to convert it to a VMDK file, since VMware operates on the VMDK format Use the qemu-img tool to perform the conversion, for example: /qemu-img.exe convert -p \NanoServer\NanoServer.vhd -O vmdk \NanoServer\NanoServer.vmdk.
Tiếp đến import file vmdk qua VMWare
Chọn sang BIOS thay vì UEFI
Chọn đến file vmdk vừa mới convert
Mở file vmx trong folder máy ảo VMWare lên
Sửa card mạng sang vmxnet3
- Cấu hình IP tĩnh cho nanoServer
Setup firewall cho phép ping đến
Inbound Firewall rules > Virtual Machine Monitoring (Echo Request – ICMPv4 – In)
Nhấn F4 để đổi sang trạng thái allow
Remote powershell, nanoServer không hỗ trợ GUI, chỉ thao tác bằng lệnh, do đó dung lượng của NanoServer rất nhẹ khoảng 1GB khi đã cài đặt IIS + DNS Server
Remote powershell bằng cách dùng powershell trên máy khác và tiến hành remote vào windows nano server để thực hiện các lệnh trên nano server
Có thể dùng powershell ISE để dễ thao tác
Enter-PSSession -ComputerName 192.168.5.4 -Credential ~\Administrator
Sau khi remote thành công, sẽ có phần IP hoặc hostname ở trước phần nhập lệnh
$s = New-PSSession -ComputerName "192.168.5.4" -Credential ~\Administrator
Lệnh trên dùng để khởi tạo session và gán session đó vào biến $s
Copy-Item -ToSession $s -Path C:\Con昀昀g\applicationHost.con昀昀g -Destination
C:\Windows\System32\inetsrv\con昀昀g\
Lệnh trên dung để copy file vào nanoServer, nếu muốn copy file từ nanoServer về máy thì thay -ToSession thành -FromSession
To configure an IIS website with PowerShell, first import the IISAdministration module using Import-Module IISAdministration Then use Get-IISSite to retrieve the sites configured in IIS, and if you need to remove a site named "Nhom05-FTP" run Remove-IISSite -Name "Nhom05-FTP" To add a new site named "Nhom05" that listens on port 80 for all hostnames, create it with New-IISSite -Name "Nhom05" -BindingInformation "*:80:" -PhysicalPath "C:\webserver", mapping the site to the physical path C:\webserver and exposing it on port 80 for any host header.
To configure a Windows DNS Server, enable the DNS Server Full-Role feature with Enable-WindowsOptionalFeature -Online -FeatureName DNS-Server-Full-Role Use Get-WindowsOptionalFeature -Online to list all available features Manage DNS with Get-DnsServer, then create a primary zone with Add-DnsServerPrimaryZone -ZoneName nhom05.org -ZoneFile nhom05.org.dns Add an A resource record for www in the nhom05.org zone pointing to 192.168.5.4 using Add-DnsServerResourceRecordA -Name www -ZoneName nhom05.org -IPv4Address 192.168.5.4 Finally, configure a secondary zone with Add-DnsServerSecondaryZone -Name "nhom05.org" -ZoneFile nhom05.org.dns.
"nhom05.org.dns" -MasterServers 192.168.5.4 o Remove-DnsServerZone "nhom05.org" -PassThru -Verbose
- Cấu hình DNS để windows nano server có thể đi phân giải tên miền internet o Get-DNSClient o Set-DnsClientServerAddress -InterfaceIndex 2
TRIỂN KHAI TRÊN GOOGLE ENGINE
- Kết quả của website + DNS
- 2 máy trạm windows server 2016, windows 7 sử dụng network adapter 2
- 1 máy trạm windows 7 sử dụng network adapter
AI TRIỂN KHAI TRÊN GOOGLE ENGINE
1 Thông tin về máy ảo của google Engine
- Sử dụng Docker để tạo 1 môi trưởng máy ảo khác o [Net.ServicePointManager]::SecurityProtocol [Net.SecurityProtocolType]::Tls12 o Register-PSRepository -Default o Install-Module -Name DockerMsftProvider -Force o Install-Package -Name docker -ProviderName
- Pull image từ docker hub về o Docker pull mcr.microsoft.com/windows/nanoserver:10.0.14393.2363 o Docker pull nanoserver/iis-php o Docker pull nanoserver/iis
- Chạy nền container từ image o Docker run -it -d mcr.microsoft.com/windows/nanoserver:10.0.14393.2363 o Docker ps -a Để xem tất cả container đã tạo
- Truy cập vào windows nano server docker o Docker exec -it powershell
Create a basic IIS website on Windows using Docker, and use docker-compose to simplify building and launching the container stack Establish a clear directory structure for the project In the Dockerfile, create a new image and copy the website files from the project directory into the container so the IIS web server serves the site directly from the image, ensuring consistent deployments and easier maintenance.
From the Docker Compose snippet, version 3.3 is declared and a single service, iis-basic, is defined The container is named iis-basic and built from the current directory (build: context: /) with the Dockerfile located at Dockerfile, using the nanoserver/iis-basic image The ports section is present but no port mappings are shown The image metadata includes a maintainer label with the contact email ntnguyen.19it5@vku.udn.vn.
- 80:80 tty: true networks: default: external: name: nat o Build và up image lên: docker-compose up –build -d o Docker ps để xem docker container đã chạy chưa
- Thêm PHP vào IIS o Tạo cấu trúc thư mục như sau o Ở file Dockerfile có nội dung như sau:
FROM nanoserver/iis-php:latest
# Metadata indicating an image maintainer #LABEL maintainer="ntnguyen.19it5@vku.udn.vn"
# Creates an HTML file and adds content to this file.
COPY /website c:/inetpub/wwwroot o Ở file docker-compose có nội dung như sau: version: "3.3" services: build: context: / dockerfile: Dockerfile image: nanoserver/iis-website-php:latest ports:
- 8080:80 tty: true networks: default: external: name: nat o Ở file index.php
o Build và up image lên: docker-compose up –build -d o Vào localhost:8080/index.php
Để trỏ tên miền về VPS, bạn có thể dùng CloudFlare để quản lý tên miền dễ dàng hơn Thêm một record A trỏ tên miền tới địa chỉ IP của VPS, sau đó có thể truy cập website bằng tên miền, ví dụ http://qtm-nhom05.uknteam.site và http://qtm-nhom05.uknteam.site:8080.