I'm encountering a 403 Forbidden error when trying to access my AWS API Gateway using a custom domain. Here's a summary of the issue:
Configuration:
- API Gateway Endpoint Type: Regional
- Custom Domain: Configured with an AWS-managed SSL certificate and using TLS 1.2 as the minimum version.
- DNS: The custom domain's DNS CNAME record is pointing directly to the API Gateway’s regional domain.
- Stage: The API works fine when accessed directly via the API Gateway’s stage URL (https://abc123.execute-api.us-west-2.amazonaws.com/prod), and logs are generated as expected.
- Logging: Enabled full logging in API Gateway, and logs are successfully generated when accessing via the stage URL.
- No CloudFront Distribution: The API is using a regional endpoint, so there’s no CloudFront distribution involved.
Issue:
When accessing the API using the custom domain URL (https://api.mydomain.com), I receive a 403 Forbidden error. The error is consistent across different clients (Postman, browser). The API Gateway logs do not show any logs for requests made through the custom domain, but logging works when accessed via the stage URL.
Steps Taken:
- Reconfigured the Custom Domain: 1. Deleted and recreated the custom domain in API Gateway. 2. Updated DNS records accordingly.
- Verified SSL and TLS: 1. Confirmed that the SSL certificate is correctly associated with the custom domain. 2. Ensured the TLS version is set to 1.2.
- Revalidated Custom Domain: Ensured the custom domain is validated in API Gateway.
- Tested Direct API Gateway URL: Confirmed that the API functions properly using the API Gateway stage URL.
Current Error:
When accessing the API via the custom domain, I receive the following error in Postman:
403 Forbidden
The request could not be satisfied. Bad request. We can't connect to the server for this app or website at this time.
There are no IP restrictions, CORS issues, or custom VPCs involved. The API is hosted in the default VPC.
Questions:
- What could be causing the 403 Forbidden error when accessing via the custom domain?
- Are there any additional configurations or permissions I need to check?
- How can I troubleshoot this issue further, especially given that the API works fine via the stage URL?
Any guidance or suggestions would be greatly appreciated!
Edit 1: I deleted the old custom domain from API gateway, and also stages, and created a new custom domain on console, with the same subdomain and SSL Certificate as before, just edge endpoint instead of regional, and now the cloudfront issue is not showing up, but I'm still getting forbidden error:
{
"message": "Forbidden"
}
Is there any thing else that I need to verify?