Advertisement
funcelot

api.<server-name>.ru

Jan 29th, 2020
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.35 KB | None | 0 0
  1. server {
  2.     server_name api.<server-name>.ru;
  3.  
  4.     root /var/www/html;
  5.  
  6.     # Add index.php to the list if you are using PHP
  7.     index index.api.<server-name>.ru.html;
  8.  
  9.     location = /health {
  10.         # First attempt to serve request as file, then
  11.         # as directory, then fall back to displaying a 404.
  12.         proxy_pass https://echo;
  13.         proxy_set_header Host $host;
  14.         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  15.         proxy_set_header X-Real-IP $remote_addr;
  16.     }
  17.  
  18.     location /ws/ {
  19.         proxy_pass http://api;
  20.         proxy_http_version 1.1;
  21.         proxy_set_header Upgrade $http_upgrade;
  22.         proxy_set_header Connection "upgrade";
  23.         proxy_read_timeout     3600s;
  24.         proxy_connect_timeout  3600s;
  25.     }
  26.  
  27.     location /wss {
  28.         proxy_pass http://api;
  29.         proxy_buffering off;
  30.         proxy_http_version 1.1;
  31.         proxy_set_header Connection "Keep-Alive";
  32.         proxy_set_header Proxy-Connection "Keep-Alive";
  33.     }
  34.  
  35.     location /ws {
  36.         proxy_pass http://api;
  37.         proxy_http_version 1.1;
  38.         proxy_set_header Upgrade $http_upgrade;
  39.         proxy_set_header Connection "upgrade";
  40.         proxy_read_timeout 86400s;
  41.         proxy_connect_timeout 86400s;
  42.     }
  43.  
  44.     location / {
  45.         proxy_pass http://api;
  46.         proxy_set_header Host $host;
  47.         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  48.         proxy_set_header X-Real-IP $remote_addr;
  49.     }
  50.  
  51.     listen [::]:443; # managed by Certbot
  52.     listen 443 ssl; # managed by Certbot
  53.     ssl_certificate /etc/letsencrypt/live/api.<server-name>.ru/fullchain.pem; # managed by Certbot
  54.     ssl_certificate_key /etc/letsencrypt/live/api.<server-name>.ru/privkey.pem; # managed by Certbot
  55.     include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  56.     ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  57.  
  58. }
  59.  
  60. server {
  61.     #if ($host = api.<server-name>.ru) {
  62.     #    return 301 https://$host$request_uri;
  63.     #} # managed by Certbot
  64.  
  65.     listen 80 ;
  66.     listen [::]:80 ;
  67.     server_name api.<server-name>.ru;
  68.  
  69.     return 404; # managed by Certbot
  70. }
  71.  
  72. upstream api {
  73.         server 127.0.0.1:8080;
  74.         keepalive 32;
  75.         keepalive_timeout 86400s;
  76.         keepalive_requests 256;
  77. }
  78.  
  79.  
  80. upstream echo {
  81.         server 127.0.0.1:8444;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement