PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, September 1, 2022

[FIXED] How do i configure a QGIS Server on an NGINX powered web server that is already serving a Laravel App

 September 01, 2022     laravel, nginx, nginx-reverse-proxy, qgis, vhosts     No comments   

Issue

I have successfully set up a QGIS Server on an Ubuntu box.

I would like to access some maps on a url say: 121.123.124.124/qgisserver

I am currently accessing my laravel app via 121.123.124.124/

I have configured the virtual host for the qgisserver as below:

server {
    listen 80;
    server_name 121.123.124.124;

    location = /qgisserver {
        gzip           off;
        include        fastcgi_params;
        fastcgi_pass   unix:/var/run/qgisserver.socket;
    }
}

following the training manual here https://docs.qgis.org/3.22/en/docs/server_manual/getting_started.html#installation-on-debian-based-systems

the laravel app host file looks like this:

server {
    listen 80;
    server_name 121.123.124.124;
    
    root /var/www/html/laravel-app/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

I have enabled the qgisserver virtual host by symlinking it in the sites-enabled folder and restarting the nginx service.

However when i access 121.123.124.124/qgisserver , it returns the default laravel 404 error page.

How can i successfully access my qgis maps via the 121.123.124.124/qgisserver location and still access the app at 121.123.124.124/

Thank you.


Solution

You shouldn't use a separate server block for that, especially with the same server name! You should already receive an nginx message like nginx: [warn] conflicting server name "121.123.124.124" on 0.0.0.0:80, ignored; doesn't it warns you that you are doing something wrong? Put that location into the same server block where laravel app is served. To prevent QGIS Server URLs from interfering with your laravel app in any way, use the ^~ location modifier:

location ^~ /qgisserver {
    gzip           off;
    include        fastcgi_params;
    fastcgi_pass   unix:/var/run/qgisserver.socket;
}


Answered By - Ivan Shatsky
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing