Cloud Native 9 min read

Run Legacy REST Apps on Alibaba Cloud Function Compute with fcapp.run & fcapp-test.run

This guide explains how to deploy existing RESTful applications, such as WordPress, on Alibaba Cloud Function Compute by leveraging the fcapp.run domain for production and the fcapp-test.run domain for local web testing, without modifying any business code.

Alibaba Cloud Native
Alibaba Cloud Native
Alibaba Cloud Native
Run Legacy REST Apps on Alibaba Cloud Function Compute with fcapp.run & fcapp-test.run

Background

Alibaba Cloud Function Compute originally offered an HTTP trigger that routes requests based on the URL path, which caused 404 errors for REST‑style applications because the function container receives a path prefixed with a routing identifier. Function Compute was designed for small, single‑function services, treating each function as an independent API.

In recent years, Custom Runtime/Custom Container Runtime support was added, allowing users to run existing applications (e.g., MVC‑based projects) without refactoring them into many tiny functions. However, these legacy REST apps still could not be accessed directly because the shared APIServer component forces path‑based routing.

Solution: Dedicated Domain for Each HTTP Trigger

Function Compute now assigns a unique domain (e.g., {random-string}.cn-shanghai.fcapp.run) to every newly created HTTP trigger. Requests to this domain are routed directly to the function container, bypassing the path‑based routing and eliminating the 404 problem.

Local Web Testing with fcapp-test.run

Due to mainland China regulations, the default Function Compute domain cannot serve web pages; responses are converted to download behavior. For API‑only functions this is acceptable, but web‑oriented functions need a way to view HTML output in a browser.

In testing environments you can use the temporary domain fcapp-test.run and add a local host entry to resolve it to the same IP as the production domain. This prevents the download conversion and enables normal web debugging.

# 1. Get the fcapp.run domain from the console
FC_DOMAIN='wordpress-xxxxx-serverlordpress-ydziwvakfn.cn-shenzhen.fcapp.run'
FC_TEST_DOMAIN=`echo ${FC_DOMAIN} | sed 's/fcapp.run/fcapp-test.run/g'`
echo "FC domain: ${FC_DOMAIN}"
echo "FC test domain: ${FC_TEST_DOMAIN}"

# 2. Resolve the domain to an IP address
FC_IP=`ping ${FC_DOMAIN} -c 1 | head -1 | awk '{print $3}' | sed 's/[():]//g'`
echo "FC IP: ${FC_IP}"

# 3. Add a host entry for the test domain (requires sudo)
sudo sh -c "printf '
${FC_IP} ${FC_TEST_DOMAIN}
' >> /etc/hosts"
cat /etc/hosts

# 4. Access the function via the test domain
curl -v "${FC_TEST_DOMAIN}"

After updating the host file, the client resolves fcapp-test.run to the Function Compute server, establishing a TCP connection and sending an HTTP request. The server then returns the expected HTML/JS content.

Deploying WordPress Using the Official Image

The following steps show how to run the official WordPress Docker image on Function Compute without changing any application code.

Prepare a Function Compute account.

Push the WordPress image to Alibaba Cloud Container Registry.

Create or use an existing MySQL instance, configure the database and credentials, and ensure VPC and whitelist settings match the Function Compute service.

Then create a function from the WordPress image, set the container's listening port to 80, and inject the MySQL connection details as environment variables.

WordPress function creation UI
WordPress function creation UI

Testing Without a Registered Domain

For testing, use the fcapp-test.run domain and the host entry described earlier. This allows you to view the WordPress site in a browser without needing a legally registered domain.

Testing WordPress via fcapp-test.run
Testing WordPress via fcapp-test.run

Production Deployment

When the site is ready for public access, bind a custom, ICP‑registered domain to the function using the Custom Domain feature, or expose the function through a standard API gateway or other cloud networking product.

Custom domain binding UI
Custom domain binding UI

Summary

The introduction of the fcapp.run domain and related features marks a significant step for Function Compute in supporting both REST and web scenarios. Users can now deploy legacy REST applications on Function Compute with zero code changes, enjoy a low‑cost, compliant testing workflow, and seamlessly transition to production with custom domains.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Cloud NativeServerlessFunction ComputeCustom RuntimeWordPressfcapp.runfcapp-test.run
Alibaba Cloud Native
Written by

Alibaba Cloud Native

We publish cloud-native tech news, curate in-depth content, host regular events and live streams, and share Alibaba product and user case studies. Join us to explore and share the cloud-native insights you need.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.