Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
How can I make nginx redirect subdomain to a folder?

How can I make nginx redirect all the requests to my subdomain to a folder?

Example:

http://sub2.sub1.domain.com/

that should indicate that sub2 is a folder in sub1.domain.com/sub2

How can I do this?

The main objective is to hide the folder to the user. So, it should continue as http://sub2.sub1.domain.com/

My wish is to use a wildcard in sub2.

UPDATE:

I've tried:

server {
    listen 80;
    listen [::]:80;

    server_name ~^(.*)\.sis\..*$;

location / {
    proxy_pass http://sis.mydomain.com/$1$request_uri;
    }
}

but it also didn't work, any error?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

In the nginx directives for sub2.sub1.domain.com you'd put:

server {
    listen 80;
    server_name sub2.sub1.domain.com;

location / {
    proxy_pass https://sub1.domain.com/sub2;
    }
}

So any request going to sub2.sub1.domain.com gets proxied to → sub1.domain.com/sub2 (while masked as sub2.sub1.domain.com); no need for a redirect or rewrite this way either.

Wildcard Method

server {
    listen 80;
    server_name ~^(.*)\.sub1\.domain\.com;

location / {
    proxy_pass https://sub1.domain.com/$1;
    }
}

*the wildcard method above is untested.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!