A sample nginx config file that redirects traffic from a domain to b domain

# This config is for old-domain.com => new-domain.com redirecting
server {
  listen 80;
  listen 443 ssl;
  server_name old-domain.com www.old-domain.com;
  location / {
    return 301 https://new-domain.com$request_uri;
  }
  #include /etc/nginx/conf.d/snippets/ssl.conf;
}


# A sample nginx config file for a reverse proxy server
server {
    server_name happynotes-img-uploader.shukebeta.com;
    client_max_body_size 10M;

    access_log  /var/log/nginx/happynotes-img-uploader.shukebeta.com.access.log;
    error_log   /var/log/nginx/happynotes-img-uploader.shukebeta.com.error.log;

    location / {
        proxy_set_header X-Forwarded-Proto https;
        proxy_pass http://127.0.0.1:3000;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    large_client_header_buffers 4 32k;

    listen [::]:80;
    listen 80;
}

Comments

  1. Markdown is allowed. HTML tags allowed: <strong>, <em>, <blockquote>, <code>, <pre>, <a>.