I’m trying to configure my web application to work with a subdirectory path instead of the root domain. Here’s my current setup:
Current Architecture:
- Frontend: React app deployed via GitHub Pages
- Backend: ASP.NET Core running in Docker container with Nginx on AWS EC2
- DNS: Managed through Hostinger
Right now everything works fine with mysite.com
for frontend and api.mysite.com
for backend, both on HTTP.
What I want to achieve:
Change from mysite.com
to mysite.com/app
as the main access point.
Configuration changes I made:
-
GitHub Pages still deploys from root directory
-
CNAME file unchanged:
mysite.com
-
Updated vite config:
base: '/app/'
-
Modified package.json:
"homepage": "mysite.com/app"
-
DNS records updated:
- Added A record:
@ ec2_ip_address
- Kept A record:
api ec2_ip_address
- Kept CNAME:
www mysite.com
- Added A record:
-
Nginx configuration addition:
server {
listen 80;
server_name mysite.com;
location /app/ {
proxy_pass https://myusername.github.io/my-repository/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_ssl_server_name on;
}
}
After deploying these changes, I’m getting a 404 “File not found” error when trying to access the subdirectory path. What am I doing wrong in this configuration? Is there a step I’m missing to make GitHub Pages work properly with subdirectory routing through Nginx proxy?