Skip to content
Snippets Groups Projects
nginx-labtest-nomad.conf 15.06 KiB
user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    server_names_hash_bucket_size  64;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;
    #gzip  on;

  tcp_nopush on;

  # i tried setting to 0 and removing the keepalive timer from the ipython client.
  # but it did not fix the problem.
  #keepalive_timeout  0;
  keepalive_timeout  1000;

  proxy_connect_timeout   90;
  proxy_send_timeout      90;
  proxy_read_timeout      1000000;
  proxy_buffers           32 4k;
  client_max_body_size    100M;
  client_body_buffer_size 128k;
  client_body_temp_path   "client_temp";
  proxy_temp_path         "client_temp";
  fastcgi_temp_path       "client_temp";
  uwsgi_temp_path         "client_temp";
  scgi_temp_path          "client_temp";

  map $http_upgrade $connection_upgrade {
      default upgrade;
      ''      close;
  }


# server {
#   listen         80;
#   server_name    labtest-nomad.esc.rzg.mpg.de;
#   return         301 https://analytics-toolkit.nomad-coe.eu$request_uri;
# }
# server {
#   listen              443 ssl;
#   server_name         labtest-nomad.esc.rzg.mpg.de;
#   ssl_certificate     /certs/cert-8701391933287641330712620431.pem;
#   ssl_certificate_key /certs/labtest-nomad.esc.rzg.mpg.de.key;
#   return              301 https://analytics-toolkit.nomad-coe.eu$request_uri;
# }


  server {
    listen         80;
    server_name    analytics-toolkit.nomad-coe.eu;
    return         301 https://$server_name$request_uri;
  }

  server {
    autoindex off;

    # enable requests for specific instances in multi-user environments
    # where a request could be routed to one of many server instances
    # /beaker/<uuid>/foo -> /foo

    listen 0.0.0.0:443 ssl;
    ssl_certificate     /web-certs/cert-chain.pem;
    ssl_certificate_key /web-certs/key.pem;
    #ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    #ssl_ciphers         HIGH:!aNULL:!MD5;
    server_name         analytics-toolkit.nomad-coe.eu;

    # redirect server error pages to the static page /50x.html and serve them directly from static html directory
    error_page   500 502 503 504  /static/50x.html;

    # redirect to the starting page
    location = / {
      return 301 $scheme://$http_host/home/;
    }

    location = /robots.txt {
      alias "/usr/share/nginx/html/static/robots.txt";
    }

    location /static/ {
      alias "/usr/share/nginx/html/static/";
    }

    location /archive-browser/ {
      try_files $uri /archive-browser/index.html;
      alias "/usr/share/nginx/html/archive-browser/";
    }
   
    location /home/ {
      alias "/usr/share/nginx/html/home/";
    }

    location = /stats/archiveGlobalStats/static {
      return 301 $scheme://$server_name/static/archiveGlobalStats.html;
    }

    location /userapi/demos {
      index index.json;
      alias "/usr/share/nginx/html/userapi/demos";
    }

    location /.well-known/ {
      alias "/usr/share/nginx/html/.well-known/";
    }
    location /nexus/ {
      proxy_pass http://130.183.207.111:31049;
      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 "https";
    }


    location /personal/ {
      #proxy_pass http://130.183.207.77:8888;
      alias "/usr/share/nginx/html/personal/";
      try_files $uri $uri/ /personal/index.html;
    }

    location /userapi/ {
      proxy_pass https://130.183.207.111:31509;
    }

    location /api/ {
      proxy_pass http://130.183.207.111:32305;
    }

    location /ui/ {
      proxy_pass http://130.183.207.111:32305;
    }

    location /nmi/ {
      proxy_pass http://130.183.207.111:32305;
    }

    location /analytics/ {
      proxy_pass http://130.183.207.111:31455;
    }

    location /archive/ {
      proxy_pass http://130.183.207.111:30668;
    }



    location /stats/ {
      proxy_pass http://130.183.207.111:31725;
    }

    location /apitest/ {
      proxy_pass http://130.183.207.111:31725;
    }

    location /jupyter/ {
      proxy_pass https://130.183.207.111:31570;
      proxy_set_header Host $http_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 "https";
      proxy_redirect off;
      proxy_buffering off;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
      proxy_read_timeout 86400;
      proxy_http_version 1.1;
    }

    location = /jupyter {
      proxy_pass https://130.183.207.111:31570;
      proxy_set_header Host $host;
      proxy_set_header Origin https://130.183.207.111:31570;
      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 "https";
    }

    location ~ "^/jupyter/api/kernels/" {
        proxy_pass https://130.183.207.111:31570;
        proxy_set_header      Host $host;
        # websocket support
        proxy_http_version    1.1;
        proxy_set_header      Upgrade "WebSocket";
        proxy_set_header      Connection "Upgrade";
        proxy_read_timeout    86400;
	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 "https";
    }
    location ~ "^/jupyter/terminals/" {
        proxy_pass https://130.183.207.111:31570;
        proxy_set_header      Host $host;
        # websocket support
        proxy_http_version    1.1;
        proxy_set_header Upgrade "WebSocket";
        proxy_set_header      Connection "Upgrade";
        proxy_read_timeout    86400;
	#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 "https";
    }

    location /industry-project-imeall/ {
      proxy_pass http://labdev-nomad.esc.rzg.mpg.de:34695;
    }

    location = /industry-project-imeall {
      proxy_pass http://labdev-nomad.esc.rzg.mpg.de:34695;
    }

    location = /Creedo {
      return 301 $scheme://$server_name/Creedo/cM/start/;
    }

    location /Creedo/ {
      proxy_pass https://130.183.207.111:30355;
    }

    rewrite "^/notebook-edit/(.*)$" /beaker/cM/start/$1 last;

    location = /Shibboleth.sso {
      proxy_pass https://130.183.207.111:31524;
    }

    location /Shibboleth.sso/ {
      proxy_pass https://130.183.207.111:31524;
    }

    location = /shibboleth {
      proxy_pass https://130.183.207.111:31524;
    }

    location /shibboleth/ {
      proxy_pass https://130.183.207.111:31524;
    }

    location = /login {
      proxy_set_header Host analytics-toolkit.nomad-coe.eu;
      proxy_set_header Origin https://130.183.207.111:31524;
      proxy_pass https://130.183.207.111:31524;
    }

    location /login/ {
      proxy_set_header Host analytics-toolkit.nomad-coe.eu;
      proxy_set_header Origin https://130.183.207.111:31524;
      proxy_pass https://130.183.207.111:31524;
    }

    #location = /beaker/#/control {
    #  return 301 $scheme://$http_host/home;
    #}

    location = /beaker {
      return 301 $scheme://$http_host/beaker/;
    }

    location /beaker/ {
      proxy_pass https://130.183.207.111:31524;
    }

    # version get request
    location = /version {
      proxy_pass https://130.183.207.111:31524;
    }

    # version get request
    location /notebook-edit/ {
      proxy_pass https://130.183.207.111:31524;
    }

    location ~ "^/[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]/beaker/rest/util/version" {
      proxy_pass https://130.183.207.111:31524;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      add_header Access-Control-Allow-Origin *;
    }

    # forward websockets, auth using path instead of token
    location ~ "^/[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]/beaker/cometd-[a-z0-9]+/" {
      proxy_pass https://130.183.207.111:31524;
      proxy_http_version 1.1; 
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }

    location ~ "^/[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]/r.[0-9]+/" {
      proxy_pass https://130.183.207.111:31524;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }

    location ~ "^/[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]/ipython.[0-9]+/api/kernels/[0-9a-z-]+/" {
      proxy_pass https://130.183.207.111:31524;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_set_header Host 127.0.0.1:8804;
      proxy_set_header Origin "http://127.0.0.1:8804";
    }

    location ~ "^/[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]/ipython.[0-9]+/" {
      proxy_pass https://130.183.207.111:31524;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_set_header Host 127.0.0.1:8804;
      proxy_set_header Origin "http://127.0.0.1:8804";
    }

     location ~ "^/[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]/python3.[0-9]+/api/kernels/[0-9a-z-]+/" {
      proxy_pass https://130.183.207.111:31524;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_set_header Host 127.0.0.1:8805;
      proxy_set_header Origin "http://127.0.0.1:8805";
    }

    location ~ "^/[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]/python3.[0-9]+/" {
      proxy_pass https://130.183.207.111:31524;
      proxy_set_header Origin "http://127.0.0.1:8805";
    } 

    location ~ "^/[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]/beaker/" {
      proxy_pass https://130.183.207.111:31524;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "upgrade";
    }

    location ~ "^/[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]/" {
      proxy_pass https://130.183.207.111:31524;
    }

    # user directory
    location /user/ {
      proxy_pass https://130.183.207.111:31524;
    }


    location = /nomad-query-gui {
      return 302 https://$server_name/notebook-edit/data/shared/tutorials/nomad-query/nomad-query.bkr;
    }

    location = /tutorial-metal-nonmetal {
      return 302 https://$server_name/notebook-edit/data/shared/tutorial/sisso/sisso-metal-nonmetal.bkr;
    }

    location = /tutorial-LASSO-L0 {
      return 302 $scheme://$server_name/notebook-edit/data/shared/tutorials/lasso/LASSO_L0.bkr;
    }

    location = /tutorial-LASSO_L0 {
      return 302 $scheme://$server_name/notebook-edit/data/shared/tutorials/lasso/LASSO_L0.bkr;
    }

    location = /tutorial-embedding {
      return 302 $scheme://$server_name/notebook-edit/data/shared/tutorials/embedding/Embedding.bkr;
    }

    location = /tutorial-SGD {
      return 302 $scheme://$server_name/Creedo/cM/start/;
    }

    location = /tutorial-glosim {
      return 302 $scheme://$server_name/notebook-edit/data/shared/tutorials/soap-similiarity/SOAP_similarity.bkr;
    }

    location = /tutorial-krr {
      return 302 $scheme://$server_name/notebook-edit/data/shared/tutorials/prototype/brprototype3.bkr;
    }

    location = /tutorial-SIS {
      return 302 https://$server_name/notebook-edit/data/shared/tutorials/sis/sis_cscl.bkr;
    }
    
    location = /tutorial-SIS-L0 {
      return 302 $scheme://$server_name/notebook-edit/data/shared/tutorials/sis/sis_cscl.bkr;
    }

    location = /tutorial-SIS_L0 {
      return 302 $scheme://$server_name/notebook-edit/data/shared/tutorials/sis/sis_cscl.bkr;
    }

    location = /tutorial-sisso-metal-non-metal {
      return 302 https://$server_name/notebook-edit/data/shared/tutorials/sisso/sisso-metal-nonmetal.bkr;
    }

    location = /tutorial-FF-fit {
      return 302 https://$server_name/notebook-edit/data/shared/tutorials/ff-fit/FF-fit.bkr;
    }

    location = /tutorial-FF_fit {
      return 302 https://$server_name/notebook-edit/data/shared/tutorials/ff-fit/FF-fit.bkr;
    }

    location = /hands-on-learning-atomic-charges {
      return 302 https://$server_name/jupyter/cM/start/data/shared/afekete/tutorial/learning_atomic_charges.ipynb;
    }

    location = /hands-on-grain-boundaries {
      return 302 https://$server_name/jupyter/cM/start/data/shared/afekete/tutorial/GB_tutorial_Berlin_2017.ipynb;
    }

    location = /tutorial-ClusterX {
      return 302 https://$server_name/notebook-edit/data/shared/tutorials/clusterX.bkr;
    }

    location = /tutorial-errorbars {
      return 302 https://$server_name/notebook-edit/data/shared/tutorials/errorbars/errorbars_html.bkr;
    }

    location = /tutorial-periodic-table  {
      return 302 https://$server_name/notebook-edit/data/shared/tutorials/periodic-table/periodic-table.bkr;
    }
    
    # location = /hands-on-cs  {
    #   return 302 https://$server_name/notebook-edit/data/shared/emrea/hands-on-tutorial_CS.bkr;
    # }

    location = /tutorial-face-of-crystals {
      return 302 http://nomad-team.rz-berlin.mpg.de:443/beaker/#/open?uri=%2Fhome%2Fbeaker%2Ftutorials%2Fface_of_crystals.bkr;
    }

    location = /custom-analytics-example {
      return 302 https://$server_name/notebook-edit/data/shared/tutorials/custom-analytics-example/custom-analytics-example.bkr;
    }

    location /jupyterhub {
        proxy_pass http://130.183.207.104:31001;
        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 Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }

    location = /hands-on-cs {
        return 302 $scheme://$server_name/jupyterhub/hub/user-redirect/notebooks/tutorials/compressed_sensing/compressed_sensing.ipynb;
    }

    location = /hands-on-cnn {
        return 302 $scheme://$server_name/jupyterhub/hub/user-redirect/notebooks/tutorials/convolutional_nn/convolutional_nn.ipynb;
    }

  }

  server {
  # nexus docker registry
      autoindex off;
 
    listen              5509 ssl;
    server_name         analytics-toolkit.nomad-coe.eu;
    ssl_certificate     /web-certs/cert-chain.pem;
    ssl_certificate_key /web-certs/key.pem;
    #ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    #ssl_ciphers         HIGH:!aNULL:!MD5;
  
    # allow large uploads of files
    client_max_body_size 1G;
  
    # optimize downloading files larger than 1G
    #proxy_max_temp_file_size 2G;
  
    location / {
      proxy_pass http://130.183.207.111:31158;
      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 "https";
    }
  }
}