Reputation: 767
I am new to the server configuration. I have two running React projects on Linode server as port
3000
and 5000
. The two React projects are different. The port 3000
is for homepage and port 5000
for admin page. Now I also purchased domain name as https://www.testeam.com. How can I map domain name to my react projects as following?
+-------|---------------|-----------------------------+
| Page | react project | Domain Name |
+-------|---------------|-----------------------------+
| Home | port 3000 | https://www.testeam.com |
+-------|---------------|-----------------------------+
| Admin | port 5000 | https://www.testeam.com/app |
+-------|---------------|-----------------------------+
Note : The admin page is accessed using different directory app
.
Upvotes: 1
Views: 2323
Reputation: 141
You can use reverse proxies for nginx. Please read more about this topic here
Assuming you only want to serve these in https, this would be the suggested server block for port 443:
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name testeam.com www.testeam.com;
# to map "Home" page
location / {
proxy_pass http://localhost:3000;
# add other proxy configurations here
}
# to map "Admin" page
location /app/ {
proxy_pass http://localhost:5000;
# add other proxy configurations here
}
# include SSL configurations here
}
Add:
If you want to make sure this works prior to adding in SSL configurations, you can use the same server block but change 443
to 80
. When you're happy with it, use port 80 only to redirect to https, then use the server block above to serve pages in https,
Hope this helps!
Upvotes: 1