title: Nginx set let's encrypt SSL for port 80 and port 8000
body: <p>I am using <strong><em>Lets Encrypt Certbot</em></strong> to generate free SSL and everything works fine.</p>
  
  <p>I am setting <code>port 80</code> for Front-End and <code>port 8000</code> for Back-End.</p>
  
  <h2>Problem is:</h2>
  
  <p>The SSL just work for <code>PORT 80</code> only and her is my NGinx config file code.</p>
  
  <h2>Front-End port 80 code:</h2>
  
  <pre><code>server {
      listen 80 default_server;
      listen [::]:80 default_server;
  
      root /var/www/html/front-end;
  
      index index.html index.htm index.php;
  
      server_name tradekeyegypt.tk www.tradekeyegypt.tk;
  
      location / {
              # First attempt to serve request as file, then
              # as directory, then fall back to displaying a 404.
              try_files $uri $uri/ /index.php$is_args$args;
      }
  
      location ~ \.php$ {
              include snippets/fastcgi-php.conf;
              fastcgi_pass unix:/run/php/php7.2-fpm.sock;
      }
  listen [::]:443 ssl ipv6only=on; # managed by Certbot
  listen 443 ssl; # managed by Certbot
  ssl_certificate /etc/letsencrypt/live/tradekeyegypt.tk/fullchain.pem; # managed by Certbot
  ssl_certificate_key /etc/letsencrypt/live/tradekeyegypt.tk/privkey.pem; # managed by Certbot
  include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
      ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  }
  </code></pre>
  
  <h2>Back-end Port 8000 Code:</h2>
  
  <pre><code>server {
  
      listen 8000 default_server;
      listen [::]:8000 default_server;
  
  
      root /var/www/html/back-end/public;
  
      index index.html index.htm index.php;
  
      location / {
              try_files $uri $uri/ /index.php$is_args$args;
      }
  
   location ~ \.php$ {
                  include snippets/fastcgi-php.conf;
  
                  fastcgi_pass unix:/run/php/php7.2-fpm.sock;
          }
  
  }
  </code></pre>