简体   繁体   English

如何在已经为 Laravel 应用程序提供服务的 NGINX 支持的 Web 服务器上配置 QGIS 服务器

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

I have successfully set up a QGIS Server on an Ubuntu box.我已经在 Ubuntu 机器上成功设置了 QGIS 服务器。

I would like to access some maps on a url say: 121.123.124.124/qgisserver我想访问 url 上的一些地图说: 121.123.124.124/qgisserver

I am currently accessing my laravel app via 121.123.124.124/我目前正在通过121.123.124.124/访问我的 laravel 应用程序

I have configured the virtual host for the qgisserver as below:我已经为 qgisserver 配置了虚拟主机,如下所示:

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遵循此处的培训手册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: laravel 应用程序主机文件如下所示:

 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.我通过在启用站点的文件夹中符号链接并重新启动 nginx 服务来启用 qgisserver 虚拟主机。

However when i access 121.123.124.124/qgisserver , it returns the default laravel 404 error page.但是,当我访问121.123.124.124/qgisserver时,它会返回默认的 laravel 404 错误页面。

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/如何通过121.123.124.124/qgisserver位置成功访问我的 qgis 地图,并且仍然可以在121.123.124.124/访问应用程序

Thank you.谢谢你。

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 ;您应该已经收到一条 nginx 消息,例如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.将该位置放入提供 laravel 应用程序的同一服务器块中。 To prevent QGIS Server URLs from interfering with your laravel app in any way, use the ^~ location modifier:要防止 QGIS 服务器 URL 以任何方式干扰您的 laravel 应用程序,请使用^~位置修饰符:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM