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

172
Views
Nginx Reverse Proxy same server_name diferent locations with SSL

I'm having trouble configuring my nginx server as a reverse proxy for different locations under the same ip address, using SSL.

Here's my nginx config file:

server {
    listen 80;
    return 301 https://$host$request_uri;
}

server {

    listen 443 default_server;
    server_name example.com;

    ssl_certificate           /etc/ssl/private/app1.crt;
    ssl_certificate_key       /etc/ssl/private/app1.key;
    ssl_certificate           /etc/ssl/private/app2.crt;
    ssl_certificate_key       /etc/ssl/private/app2.key;

    ssl on;
    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;

    #App1
    location ^~ / {

      proxy_set_header        Host $host;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        X-Forwarded-Proto $scheme;

      proxy_pass          https://10.0.x.x/;
    }

    #App2
    location ^~ /subdomain{

      proxy_set_header        Host $host;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        X-Forwarded-Proto $scheme;

      proxy_pass          https://10.0.x.x/;
    }    
}

The above code works for the first location 'https://example.com/', but it does not work for 'https://example.com/subdomain'.

Can anyone provide some guidance on how to do this properly?

over 4 years ago · Santiago Trujillo
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!