GeoServer behinds nginx HTTPS reverse proxy

กรณีที่ใช้ nginx เป็น HTTPS reverse proxy บังหน้า geoserver ด้านหลัง มีต้องตั้งค่าเพิ่มเติมดังนี้

Proxy Base URL

สามารถตั้งได้หลายทาง

  • ใส่ใน WEB-INF/web.xml
    <context-param>
      <param-name>PROXY_BASE_URL</param-name>
      <param-value>https://fqdn-hostname/geoserver</param-value>
    </context-param>

  • ทางหน้า GUI (Global Settings)
  • ใส่ใน global.xml ใน data_dir
<proxyBaseUrl>https://fqdn-hostname/geoserver</proxyBaseUrl>

CSRF WHITELIST

บางครั้งถ้าลองกดทำ action บางอย่าง เช่น เปลี่ยนรหัสผ่าน แล้วเจอปัญหา HTTP Status 400 – Bad Request Type Status Report Message Origin does not correspond to request Description The server cannot or will not process the request due to something that is perceived to be a client error ให้ใส่ประมาณนี้ใน web.xml

<context-param>
     <param-name>GEOSERVER_CSRF_WHITELIST</param-name>
     <param-value>fqdn-hostname</param-value>
</context-param>

<filter>
    <filter-name>cross-origin</filter-name>
    <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
    <init-param>
        <param-name>cors.allowed.origins</param-name>
        <param-value>*</param-value>
    </init-param>
    <init-param>
        <param-name>cors.allowed.methods</param-name>
        <param-value>GET,POST,PUT,DELETE,HEAD,OPTIONS</param-value>
    </init-param>
    <init-param>
        <param-name>cors.allowed.headers</param-name>
        <param-value>*</param-value>
    </init-param>
</filter>

Leave a comment