#How can i create a subdomain to deploy django as api and in the main domain run react native

4 messages · Page 1 of 1 (latest)

latent wasp
#

I have a vps server in hotinger and a domain, i am looking for deloy the django backend in a subdomain and the front end with the main domain. I will use nginx, can i deploy both in the vps and use subdomain.

thorn widget
#

Yes

#

Then just use nginx as a proxy

latent wasp
# thorn widget Yes

i am getting BAD REQUEST 400 when i access sub.domain.com, i have this nginx file in /etc/nginx/sites-available/sub.domain, it loaded the without the error when i had DEBUG=True and `` ALLOWED_HOST = ["*"] in django settings. the django is running on 0.0.0.0:8000 with gunicorn. i changes them and now it is showing 400.

server_tokens               off;
access_log                  /var/log/nginx/sub.domain.com.access.log;
error_log                   /var/log/nginx/sub.domain.com.error.log;

# Return 444 status code & close connections if no Host header present
server {
  listen            80;
  return            444;
}

# Redirect HTTP to HTTPS 
server {
  server_name               sub.domain.com;
  listen                    80;
  return                 307 https://$host$request_uri;
}

server {
  location / {
    proxy_pass              http://localhost:8000;
    proxy_set_header        Host $host;
    proxy_set_header        X-Forwarded-Proto $scheme;
    proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
  }
  location /static {
      autoindex on;
      alias /var/www/sub.domain.com/static/;
  }

    listen 443 ssl; # managed by Certbot
    # rest that cerbot generated
}```