Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Configure NginX on RHEL 6.6

Attila Levente EGYEDI edited this page Apr 8, 2016 · 16 revisions

Edit the configuration file:

sudo vi /etc/nginx/conf.d/default.conf

Add the below content before the existing server block:

Note: The below content is included in the http block if the main configuration file.

proxy_http_version 1.1; # this is essential for chunked responses to work
proxy_buffering    off;
proxy_set_header   X-Real-IP $remote_addr;
proxy_set_header   X-Scheme $scheme;
proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header   Host $http_host;

upstream cedar-backend-template {
  server 127.0.0.1:9001;
}

upstream cedar-backend-repo {
  server 127.0.0.1:9002;
}

upstream cedar-backend-schema {
  server 127.0.0.1:9003;
}

upstream cedar-backend-terminology {
  server 127.0.0.1:9004;
}

upstream cedar-backend-user {
  server 127.0.0.1:9005;
}

upstream cedar-backend-valuerecommender {
  server 127.0.0.1:9006;
}

upstream cedar-backend-resource {
  server 127.0.0.1:9007;
}

upstream cedar-backend-folder {
  server 127.0.0.1:9008;
}

upstream cedar-backend-auth-https {
  server 127.0.0.1:8543;
}

server {
  listen              80;
  server_name         cedar.metadatacenter.net;
  return              301 https://$server_name$request_uri;
}

server {
  listen              443 ssl;
  server_name         cedar.metadatacenter.net;
  ssl_certificate     /etc/nginx/ssl/cedar.metadatacenter.net.crt;
  ssl_certificate_key /etc/nginx/ssl/cedar.metadatacenter.net.key;
  location / {
    root /srv/cedar/cedar-template-editor/app/;
    try_files $uri /index.html;
  }
}

server {
  listen              80;
  server_name         template.metadatacenter.net;
  return              301 https://$server_name$request_uri;
}

server {
  listen              443 ssl;
  server_name         template.metadatacenter.net;
  ssl_certificate     /etc/nginx/ssl/cedar.metadatacenter.net.crt;
  ssl_certificate_key /etc/nginx/ssl/cedar.metadatacenter.net.key;
  location / {
      proxy_pass      http://cedar-backend-template;
  }
}

server {
  listen              80;
  server_name         repo.metadatacenter.net;
  return              301 https://$server_name$request_uri;
}

server {
  listen              443 ssl;
  server_name         repo.metadatacenter.net;
  ssl_certificate     /etc/nginx/ssl/cedar.metadatacenter.net.crt;
  ssl_certificate_key /etc/nginx/ssl/cedar.metadatacenter.net.key;
  location / {
      proxy_pass      http://cedar-backend-repo;
  }
}

server {
  listen              80;
  server_name         schema.metadatacenter.net;
  return              301 https://$server_name$request_uri;
}

server {
  listen              443 ssl;
  server_name         schema.metadatacenter.net;
  ssl_certificate     /etc/nginx/ssl/cedar.metadatacenter.net.crt;
  ssl_certificate_key /etc/nginx/ssl/cedar.metadatacenter.net.key;
  location / {
      proxy_pass      http://cedar-backend-schema;
  }
}

server {
  listen              80;
  server_name         terminology.metadatacenter.net;
  return              301 https://$server_name$request_uri;
}

server {
  listen              443 ssl;
  server_name         terminology.metadatacenter.net;
  ssl_certificate     /etc/nginx/ssl/cedar.metadatacenter.net.crt;
  ssl_certificate_key /etc/nginx/ssl/cedar.metadatacenter.net.key;
  location / {
      proxy_pass      http://cedar-backend-terminology;
  }
}

server {
  listen              80;
  server_name         user.metadatacenter.net;
  return              301 https://$server_name$request_uri;
}

server {
  listen              443 ssl;
  server_name         user.metadatacenter.net;
  ssl_certificate     /etc/nginx/ssl/cedar.metadatacenter.net.crt;
  ssl_certificate_key /etc/nginx/ssl/cedar.metadatacenter.net.key;
  location / {
      proxy_pass      http://cedar-backend-user;
  }
}

server {
  listen              80;
  server_name         valuerecommender.metadatacenter.net;
  return              301 https://$server_name$request_uri;
}

server {
  listen              443 ssl;
  server_name         valuerecommender.metadatacenter.net;
  ssl_certificate     /etc/nginx/ssl/cedar.metadatacenter.net.crt;
  ssl_certificate_key /etc/nginx/ssl/cedar.metadatacenter.net.key;
  location / {
      proxy_pass      http://cedar-backend-valuerecommender;
  }
}

server {
  listen              80;
  server_name         resource.metadatacenter.net;
  return              301 https://$server_name$request_uri;
}

server {
  listen              443 ssl;
  server_name         resource.metadatacenter.net;
  ssl_certificate     /etc/nginx/ssl/cedar.metadatacenter.net.crt;
  ssl_certificate_key /etc/nginx/ssl/cedar.metadatacenter.net.key;
  location / {
      proxy_pass      http://cedar-backend-resource;
  }
}

server {
  listen              80;
  server_name         folder.metadatacenter.net;
  return              301 https://$server_name$request_uri;
}

server {
  listen              443 ssl;
  server_name         folder.metadatacenter.net;
  ssl_certificate     /etc/nginx/ssl/cedar.metadatacenter.net.crt;
  ssl_certificate_key /etc/nginx/ssl/cedar.metadatacenter.net.key;
  location / {
      proxy_pass      http://cedar-backend-folder;
  }
}

server {
  listen              80;
  server_name         auth.metadatacenter.net;
  return              301 https://$server_name$request_uri;
}

server {
  listen              443 ssl;
  server_name         auth.metadatacenter.net;
  ssl_certificate     /etc/nginx/ssl/cedar.metadatacenter.net.crt;
  ssl_certificate_key /etc/nginx/ssl/cedar.metadatacenter.net.key;
  location / {
      proxy_pass      https://cedar-backend-auth-https;
  }
}

server {
  listen              80;
  server_name         cert.metadatacenter.net;
  root                /srv/cedar/cedar-conf/static-content/dev02/cert.metadatacenter.net;
  location / {
      index           index.html;
  }
}

Restart nginx

sudo service nginx restart
Clone this wiki locally