WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Automation / Quick Tip - Easily host VMware Cloud Foundation (VCF) Offline Depot using Python SimpleHTTPServer with Authentication

Quick Tip - Easily host VMware Cloud Foundation (VCF) Offline Depot using Python SimpleHTTPServer with Authentication

01.29.2025 by William Lam // Leave a Comment

In IT, you never know when you need to quickly spin up a web server for hosting files ... One of my favorite and super easy way to do this is by leveraging Python's SimpleHTTPServer which can immediately serve files within a directory with this 1-liner:

python -m http.server 9000

This certainly beats standing up a full blown web server if you just need GET and HEAD operations.

If you do not require authentication for serving your files, then this solution fits the bill perfectly! However, if you require authentication, then I typically resort to deploying a full blown web server and use .htaccess to manage users and passwords.

For customers that have a need to host a VMware Cloud Foundation (VCF) offline depot or any VMware-based offline depot, the solution will typically require a web server due to the authentication requirements. With that said, I have recently been using an alternative method, especially if you just need to quickly host some files for say an upgrade or deployment.

I came this awesome modified version of the Python SimpleHTTPServer to easily support username and password for basic authentication, which would could be used to easily serve content to SDDC Manager. Today, VCF 5.x still requires an HTTPS endpoint and the script can be adapted to support TLS endpoint which would require certificate and private key as input.

Step 1 - Download either the original http_server_auth.py script for HTTP or this modified http_server_auth.py version (thanks to ChatGPT) for HTTPS to a system that has the Python runtime, which can even be you local workstation. I typically work on macOS, so that is perfect as I can serve the files directly from my desktop.

Step 2 - Create the necessary folder structure and content that you wish to host

Step 3 - Start the Python script with your desired parameters including the ability to specify the directory to serve the content over HTTP:

python http_server_auth.py --bind 192.168.30.4 --user vcf --password vcf123! --port 8888 --directory depot

To serve over HTTPs, you can use the following

python3 http_server_auth.py --bind 192.168.30.4 --user vcf --password vcf123! --port 443 --directory depot --certfile ~/cert.crt --keyfile ~/key.pem

If I open a web browser to that address/port, I can see I am now prompted for authentication.


Once I have successfully authenticated, I can now access the content without the need to deploy a complex web server and setup htaccess!


The next time you need to quickly host something that requires authentication, you may want to consider this quick and dirty solution!

Note: For those consuming this with VCF 5.x, if you are using a self-signed TLS certificate, you will need to also import the certificate into the SDDC Manager keystore, see this blog post for more details.

More from my site

  • ESXi on GMKtec NucBox K11
  • Quick Tip - VMware Cloud Foundation (VCF) Bringup fails without persistent ESX-OSData
  • Enhancements to VMware Cloud Foundation (VCF) & vSphere Automated Lab Deployment Scripts
  • vSAN ESA hardware mock VIB for physical ESXi deployment for VMware Cloud Foundation (VCF)
  • Passwordless login to vCenter Server or VMware Cloud Foundation (VCF) using Apple Face ID or Yubico YubiKey

Categories // Automation, VMware Cloud Foundation Tags // VMware Cloud Foundation

Thanks for the comment!Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • VMware Flings is now available in Free Downloads of Broadcom Support Portal (BSP) 05/19/2025
  • VMUG Connect 2025 - Minimal VMware Cloud Foundation (VCF) 5.x in a Box  05/15/2025
  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025

 

Loading Comments...