Advertisement
lukibeni

nginx config

Oct 4th, 2022
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.80 KB | None | 0 0
  1. #http {
  2. # map $http_accept_language $accept_language {
  3. # ~*^hu hu;
  4. # }
  5. #}
  6.  
  7. server {
  8. listen 443 ssl;
  9. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
  10. server_name app.medalyst.io;
  11.  
  12. root /opt/dist;
  13. ssl on;
  14. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  15. ssl_ciphers HIGH:!aNULL:!MD5;
  16.  
  17. #put your certificate here:
  18. ssl_certificate /etc/nginx/ssl/medalyst_chain_cert.pem;
  19. #and the key for it here:
  20. ssl_certificate_key /etc/nginx/ssl/medalyst_key.pem;
  21.  
  22. if ($accept_language ~ "^$") {
  23. set $accept_language "en";
  24. }
  25.  
  26. rewrite ^/((?!hu)(?!en)(?!de)(?!api)(?!resource).*)$ /$accept_language/$1 permanent;
  27.  
  28. location /hu/ {
  29. alias /opt/dist/hu/;
  30. try_files $uri$args $uri$args/ /hu/index.html;
  31. }
  32.  
  33. location /en/ {
  34. alias /opt/dist/en/;
  35. try_files $uri$args $uri$args/ /en/index.html;
  36. }
  37.  
  38. location /de/ {
  39. alias /opt/dist/de/;
  40. try_files $uri$args $uri$args/ /de/index.html;
  41. }
  42.  
  43.  
  44. location /resource/image {
  45. alias /opt/medalyst/data;
  46. }
  47.  
  48. location /api {
  49.  
  50. if ($request_method = 'OPTIONS') {
  51. add_header 'Access-Control-Allow-Origin' '*';
  52. add_header 'Access-Control-Allow-Credentials' 'true';
  53. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  54. add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  55. add_header 'Access-Control-Max-Age' 1728000;
  56. add_header 'Content-Type' 'text/plain charset=UTF-8';
  57. add_header 'Content-Length' 0;
  58. return 204;
  59. }
  60.  
  61. if ($request_method = 'POST') {
  62. add_header 'Access-Control-Allow-Origin' '*';
  63. add_header 'Access-Control-Allow-Credentials' 'true';
  64. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  65. add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  66. }
  67. if ($request_method = 'GET') {
  68. add_header 'Access-Control-Allow-Origin' '*';
  69. add_header 'Access-Control-Allow-Credentials' 'true';
  70. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  71. add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  72. }
  73.  
  74. proxy_set_header X-Forwarded-Host $host;
  75. proxy_set_header X-Forwarded-Server $host;
  76. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  77. proxy_pass http://127.0.0.1:8080/api;
  78. }
  79. }
  80.  
  81. server {
  82. listen 80;
  83. server_name app.medalyst.io;
  84. location / {
  85. return 301 https://app.medalyst.io$request_uri;
  86. }
  87. }
  88.  
  89. server {
  90. listen 443;
  91. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
  92.  
  93. server_name app.medalyst.io;
  94. location / {
  95.  
  96. if ($request_method = 'OPTIONS') {
  97. add_header 'Access-Control-Allow-Origin' '*';
  98. add_header 'Access-Control-Allow-Credentials' 'true';
  99. add_header 'Access-Control-Allow-Methods' 'GET, POST, 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';
  101. add_header 'Access-Control-Max-Age' 1728000;
  102. add_header 'Content-Type' 'text/plain charset=UTF-8';
  103. add_header 'Content-Length' 0;
  104. return 204;
  105. }
  106.  
  107. if ($request_method = 'POST') {
  108. add_header 'Access-Control-Allow-Origin' '*';
  109. add_header 'Access-Control-Allow-Credentials' 'true';
  110. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  111. add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  112. }
  113. if ($request_method = 'GET') {
  114. add_header 'Access-Control-Allow-Origin' '*';
  115. add_header 'Access-Control-Allow-Credentials' 'true';
  116. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  117. add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  118. }
  119. return 301 https://app.medalyst.io$request_uri;
  120. }
  121. }
  122.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement