[Qgis-user] QGIS Server and PostgreSQL projects

Alessandro Pasotti apasotti at gmail.com
Fri Sep 6 07:35:41 PDT 2024


Another possibility:
https://docs.qgis.org/3.34/en/docs/server_manual/catalog.html

You will need co configure an env variable:
QGIS_SERVER_LANDING_PAGE_PROJECTS_PG_CONNECTIONS

all projects stored in the connections above will be listed in the catalog.


On Fri, Sep 6, 2024 at 4:26 PM Abel Gonzalez via QGIS-User <
qgis-user at lists.osgeo.org> wrote:

> Hi! I just installed QGIS server on my windows server under Apache HTTPD
> and postgres in the sabe server and works fine.  There after if you want to
> show the qgis projects on a map you should install QGIS Web Client or
> Lizmap. In order to serve WMS, WFS , etc qgis project should no be saved on
> postgis, otherwise will require extra configuration.
> Good luck!
> Abel
>
> Den fre 6 sep. 2024 16:09User Adminofff via QGIS-User <
> qgis-user at lists.osgeo.org> skrev:
>
>> Hi,
>>
>> I'm trying to make QGIS Server to serve projects from PostgreSQL database
>> on the web.
>> Could anyone tell me please, is it possible to do that, or I can serve
>> only files?
>>
>> The general workflow should look like this:
>>
>> 1. Operators with QGIS Desktop are connecting to PostgreSQL, and
>> create/modify projects in it.
>> No files are involved. This part works, I was able to save test project
>> on one system, and open it on the other.
>>
>> 2. After finishing project creation/modification, Operators send a link
>> to it to the consumers/implementors.
>> The idea is to be able to view the project in a browser on any device. No
>> editing is needed, at least at this moment.
>> I've installed QGIS Server on the same host as PostgreSQL, set
>> nginx/related stuff, and tested that it successfully serves file project.
>> Then I've tried to get the project from database. qgis user, under which
>> QGIS server is run, was allowed passwordless connection to PostgreSQL via
>> localhost.
>>
>> Having test URL for file like this
>>
>> https://domain.com/qgisserver/cgi-bin/qgis_mapserv.fcgi?LAYERS=countries&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&CRS=EPSG:4326&WIDTH=400&HEIGHT=200&BBOX=-90,-180,90,180&MAP=/home/qgis/projects/world.qgs
>>
>> I've replaced file path with naive PostgreSQL URL like this
>>
>> https://domain.com/qgisserver/cgi-bin/qgis_mapserv.fcgi?LAYERS=countries&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&CRS=EPSG:4326&WIDTH=400&HEIGHT=200&BBOX=-90,-180,90,180&MAP=postgresql://127.0.0.1:5432?sslmode=disable&dbname=qgis&schema=world&project=world
>> But got this error:
>>
>> <ServerException>
>> Project file error. For OWS services: please provide a SERVICE and a MAP
>> parameter pointing to a valid QGIS project file
>> </ServerException>
>>
>> The error says that QGIS Server wants file, no mentions about database.
>> On other hand, documentation below says that for MAP parameter either
>> file path or PostgreSQL URL is needed, so it should work?
>>
>>
>> https://docs.qgis.org/3.34/en/docs/server_manual/config.html#qgis-server-envvar
>> QGIS_PROJECT_FILE
>> The .qgs or .qgz project file, normally passed as a parameter in the
>> query string (with MAP), you can also set it as an environment variable
>> (for example by using mod_rewrite Apache module).
>>
>> **Note that you may also indicate a project stored in PostgreSQL**, e.g.
>> postgresql://localhost:5432?sslmode=disable&dbname=mydb&schema=myschema&project=myproject
>> or inside a geopackage file, e.g.
>> geopackage:/path/to/geopackage/file.gpkg?projectName=myProjectName.
>>
>>
>> Searching in the Internet for the error above, I've found this bug report
>> https://github.com/qgis/QGIS/issues/31192
>>
>> From which I've got the idea to encode PostgreSQL URL in test URL, but it
>> didn't work with the same error as above.
>> Also, it looks like report author is connecting with QGIS Desktop to QGIS
>> Server, not browser, so this is not my case?
>> Also-also, as I've stuck with nginx for unrelated to QGIS reasons, I
>> cannot test proposed there Apache rewrite magic.
>>
>> I've tried to see if there is anything useful in QGIS Server logs, but
>> there are no any related messages in them.
>> I've set QGIS_SERVER_LOG_PROFILE to true, but that didn't change
>> anything. I see my request to QGIS server only in nginx logs, but nothing
>> in QGIS Server logs, and no even failed connection attempts in PostgreSQL
>> logs.
>>
>> So, is there any way to have PostreSQL projects served via QGIS Server,
>> or I can use only files?
>> _______________________________________________
>> QGIS-User mailing list
>> QGIS-User at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>
> _______________________________________________
> QGIS-User mailing list
> QGIS-User at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>


-- 
Alessandro Pasotti
QCooperative:  www.qcooperative.net
ItOpen:   www.itopen.it
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20240906/fef09bc9/attachment.htm>


More information about the QGIS-User mailing list