Advertisement
morcano

Untitled

Jul 5th, 2019
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 3.53 KB | None | 0 0
  1. upstream node {
  2.     ip_hash;
  3.     server paqt.chat:4000;
  4. }
  5.  
  6. # frontend, redirecting to https
  7. server {
  8.     listen 80;
  9.     server_name paqt.chat;
  10.  
  11.     root /var/www/html/frontend_build;
  12.  
  13.     access_log /var/log/nginx/frontend-access.log;
  14.     error_log /var/log/nginx/frontend-error.log;
  15.     index index.html;
  16.  
  17.     location /.well-known/acme-challenge/ {
  18.         root /var/www/certbot;
  19.     }
  20.  
  21.     location / {
  22.         return 301
  23.         https://$host$request_uri;    
  24.     }    
  25. }
  26.  
  27. # frontend build
  28. server {
  29.     listen 443 ssl;
  30.     server_name paqt.chat;
  31.  
  32.     root /var/www/html/frontend_build;
  33.  
  34.     access_log /var/log/nginx/frontend-access.log;
  35.     error_log /var/log/nginx/frontend-error.log;
  36.     index index.html;
  37.  
  38.     ssl_certificate /etc/letsencrypt/live/paqt.chat/fullchain.pem;
  39.     ssl_certificate_key /etc/letsencrypt/live/paqt.chat/privkey.pem;
  40.    
  41.     include /etc/letsencrypt/options-ssl-nginx.conf;
  42.     ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
  43.  
  44.     location / {
  45.         try_files $uri /index.html =404;
  46.     }
  47.  
  48.     location /static {
  49.         try_files $uri =404 @nodejs;
  50.     }
  51.  
  52.     location @nodejs {
  53.         proxy_pass http://node;
  54.         proxy_http_version 1.1;
  55.         proxy_set_header Upgrade $http_upgrade;
  56.         proxy_set_header Connection 'upgrade';
  57.         proxy_set_header Host $host;
  58.         proxy_cache_bypass $http_upgrade;
  59.     }
  60.  
  61.     # To allow POST on static pages
  62.     error_page  405     =200 $uri;
  63.  
  64. }
  65.  
  66. # php backend
  67. server {
  68.     listen 8081 ssl;
  69.     server_name paqt.chat;
  70.  
  71.     root /var/www/html/public;
  72.     index index.php  index.html index.htm;
  73.  
  74.     access_log /var/log/nginx/access.log;
  75.     error_log /var/log/nginx/error.log;
  76.  
  77.     ssl_certificate /etc/letsencrypt/live/paqt.chat/fullchain.pem;
  78.     ssl_certificate_key /etc/letsencrypt/live/paqt.chat/privkey.pem;
  79.    
  80.     include /etc/letsencrypt/options-ssl-nginx.conf;
  81.     ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
  82.  
  83.     location / {
  84.         try_files $uri $uri/ /index.php?$args;
  85.     }
  86.  
  87.     location ~ \.php$ {
  88.         if ($request_method = 'OPTIONS') {
  89.             add_header 'Access-Control-Allow-Origin' '*' always;
  90.             add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
  91.             add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Authorization';
  92.             add_header 'Access-Control-Max-Age' 1728000;
  93.             add_header 'Content-Type' 'text/plain; charset=utf-8';
  94.             add_header 'Content-Length' 0;
  95.             return 204;
  96.         }
  97.         if ($request_method ~ 'POST|GET|PUT|DELETE') {
  98.             add_header 'Access-Control-Allow-Origin' '*' always;
  99.             add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
  100.             add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
  101.             add_header 'Access-Control-Expose-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Authorization';
  102.         }
  103.  
  104.         try_files $uri =404;
  105.         fastcgi_split_path_info ^(.+\.php)(/.+)$;
  106.         fastcgi_pass phpfpm:9000;
  107.         fastcgi_index index.php;
  108.         include fastcgi_params;
  109.         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  110.         fastcgi_param PATH_INFO $fastcgi_path_info;
  111.     }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement