I have a DigitalOcean droplet for testing purposes and usually I deploy static websites, NodeJS APIs and Laravel projects and in order to get the Laravel and the NodeJS servers working in the same droplet, I need to set a different port for each one using Nginx and FirewallD to open the port.

The following Nginx server block works with any Laravel version and it’s been used under CentOS 6.x and 7.x

server {
  listen 2500;
  listen [::]:2500;

  server_name my_project.com;
  client_max_body_size 4m;

  root /var/www/my_project/public;
    index  index.php;

  access_log /var/log/nginx/my_project.access.log;
  error_log /var/log/nginx/my_project.error.log;

  location / {

    root  /var/www/my_project/public;
    try_files $uri $uri/ /index.php$is_args$args;
    index  index.html index.htm index.php;
  location ~ \.php$ {

    root  /var/www/my_project/public;
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    try_files $uri $uri/ index.php /index.php$is_args$args;
    include /etc/nginx/fastcgi_params;

    fastcgi_param SCRIPT_FILENAME $request_filename;
    fastcgi_param APP_ENV dev;

  sendfile off;


# Create a new .conf file

nano /etc/nginx/conf.d/my_project.conf

# Paste the server block code and save with Ctrl + X

# Reload and restart the Nginx server

service nginx reload && service nginx restart