Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. import * as express from 'express';
  2. import * as subdomain from 'express-subdomain'; // See subdomain package
  3.  
  4. import { UserRoutes } from './User';
  5. import { AuthRoutes } from './Auth';
  6.  
  7. export class Router {
  8. static routeAPI(app) {
  9. const router = express.Router();
  10.  
  11. router.use((req, res, next) => {
  12. res.header('Access-Control-Allow-Origin', '*');
  13. res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,PATCH');
  14. res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
  15. next();
  16. });
  17.  
  18. AuthRoutes.route(router);
  19. UserRoutes.route(router);
  20.  
  21. app.use(subdomain('api', router)); // App uses subdomain
  22. }
  23. }
  24.  
  25. server {
  26. listen 80;
  27.  
  28. server_name api.localhost;
  29.  
  30. return 301 https://$host$request_uri;
  31. }
  32.  
  33. server {
  34. listen 443 ssl;
  35.  
  36. server_name api.localhost;
  37. access_log /var/log/nginx/api.localhost.log;
  38.  
  39. ssl_certificate /etc/letsencrypt/live/api.localhost/fullchain.pem;
  40. ssl_certificate_key /etc/letsencrypt/live/api.localhost/privkey.pem;
  41.  
  42. ssl_stapling on;
  43. ssl_stapling_verify on;
  44.  
  45. location / {
  46. proxy_pass http://localhost:8080;
  47. proxy_http_version 1.1;
  48. proxy_set_header Upgrade $http_upgrade;
  49. proxy_set_header Connection 'upgrade';
  50. proxy_set_header Host $host;
  51. proxy_cache_bypass $http_upgrade;
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement