{% extends '../../base.html.twig' %}

{% block body %}
  <div class="container-fluid">
    <div class="row flex-xl-nowrap">
      {% include '../../../documentation/navbar.html.twig' with {
        'route' : nodefony.route
      } %}
      <main class="col-12 col-md-9 col-xl-8 py-md-3 pl-md-5" style="top: 5rem;">
        <div class="page-header">
          <h1>
            Nginx
          </h1>
        </div>

        <h2>You can use nginx in front of nodefony framework
        </h2>
        <div class="doc2">
          <h3>
            Example Generate nginx configuration :
          </h3>

          <pre><code class="hljs shell">$ nodefony
    _   _    ___    ____    _____   _____    ___    _   _  __   __
   | \ | |  / _ \  |  _ \  | ____| |  ___|  / _ \  | \ | | \ \ / /
   |  \| | | | | | | | | | |  _|   | |_    | | | | |  \| |  \ V /
   | |\  | | |_| | | |_| | | |___  |  _|   | |_| | | |\  |   | |
   |_| \_|  \___/  |____/  |_____| |_|      \___/  |_| \_|   |_|

Version : 4.0.0-beta.5 Platform : darwin Process : nodefony PID : 26289

Thu Sep 13 2018 15:20:52 INFO nodefony : WELCOME PROJECT : nodefony-core 4.0.0-beta.5
?  Nodefony CLI :  Generater
?  Nodefony CLI :  (Use arrow keys)
Generate New Bundle
Generate New Controller
Generate New Service
Generate New Entity
Generate New Nodefony Project
Generate Openssl Certificates
Generate Haproxy Configuration
❯ <h3>Generate Nginx Configuration </h3>
Generate letsEncrypt Webroot Configuration
--------
                       _
       _ __     __ _  (_)  _ __   __  __
      | '_ \   / _` | | | | '_ \  \ \/ /
      | | | | | (_| | | | | | | |  >  <
      |_| |_|  \__, | |_| |_| |_| /_/\_\
               |___/

? Enter Server Domain Name :  myproject.com
? Enter Server HTTP Port :  80
? Enter Server HTTPS Port :  443
? Enter Domain Remote Proxy Nodefony :  localhost
? Enter Proxy Remote Nodefony HTTP Port :  5151
? Enter Proxy Remote Nodefony HTTPS Port :  5152
? Enter Name Configuration File  :  myproject.conf
? Enter Path Configuration File  :  /Users/cci/repository/myproject/config/nginx
Thu Sep 13 2018 15:25:03 INFO COMMAND generate TASK nginx : Success Creation Configuration File :  /Users/cci/repository/myproject/config/nginx/myproject.conf
Thu Sep 13 2018 15:25:03 INFO KERNEL CONSOLE  : NODEFONY Kernel Life Cycle Terminate CODE : 0

          </code></pre>

          <h3>
            Link this file in nginx configuration file  ./config/nginx/myproject.conf :
          </h3>
          <pre><code class="hljs nginx">
map $http_upgrade $connection_upgrade {
	default upgrade;
	''      close;
}

# MINIMAL CONFIGURATION HTTP SERVER
server {
  listen 80;
  server_name myproject.com;

  set  $via  "myproject.com NGINX $nginx_version";
  if ($http_via) {
    set $via  "$http_via, $via";
  }

  location / {
    root /Users/cci/repository/myproject/web ;
    proxy_pass http://localhost:5151;
    proxy_pass_header Server;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Port $server_port;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Via  $via;
    proxy_cache_bypass $http_upgrade;
  }

  # STATICS FILES
  location ~ \.(js|css|png|ico|jpg|jpeg|gif|ttf|font|map|woff.?|twig|txt|html|xml|json|mp3|wmv|avi|mpg|mpeg|mp4|webm|swf|flv)$ {
    access_log off;
    root /Users/cci/repository/myproject/web;
    expires 7d;
  }
}

# MINIMAL CONFIGURATION HTTPS SERVER
server {
  listen      443 ssl http2;
  server_name myproject.com;

  #add_header X-Frame-Options "SAMEORIGIN";

  ssl_certificate  /Users/cci/repository/myproject/config/certificates/server/fullchain.pem;
  ssl_certificate_key /Users/cci/repository/myproject/config/certificates/server/privkey.pem;
  ssl_trusted_certificate /Users/cci/repository/myproject/config/certificates/server/fullchain.pem;

  set  $via  "myproject.com NGINX $nginx_version";
  if ($http_via) {
    set $via  "$http_via, $via";
  }

  location / {
    root /Users/cci/repository/myproject/web ;
    proxy_pass https://localhost:5152;
    proxy_pass_header Server;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Port $server_port ;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header  Via  $via;
    proxy_cache_bypass $http_upgrade;
  }

  # RAPID STATICS FILES
  location ~ \.(js|css|png|ico|jpg|jpeg|gif|ttf|font|map|woff.?|twig|txt|html|xml|json|mp3|wmv|avi|mpg|mpeg|mp4|webm|swf|flv)$ {
    root /Users/cci/repository/myproject/web;
    expires 7d;
    access_log off;
  }

}
          </code></pre>
        </div>



      </main>
    </div>
  </div>
{% endblock %}
