Skip to Main Content

ORDS, SODA & JSON in the Database

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Specifing the base URL for links or using relative links

Patrick JolliffeSep 27 2018 — edited Oct 11 2018

We are using nginx as reverse proxy in front of ORDS running on Tomcat to convert http requests to https.

Developers are complaining that links within JSON responses are not taking this into account.

For example the following handler:

BEGIN

  ORDS.define_handler(

    p_module_name    => 'patmod',

    p_pattern        => 'dual/',

    p_method         => 'GET',

    p_source_type    => ORDS.source_type_collection_feed,

    p_source         => 'SELECT dummy FROM dual',

    p_items_per_page => 0);

   

  COMMIT;

END;

/

When I go to the URL, https://ords.server/ords/db/patrick/patmod/dual/ I get the following response:

{

    "items": [

        {

            "dummy": "X"

        }

    ],

    "hasMore": false,

    "limit": 0,

    "offset": 0,

    "count": 1,

    "links": [

        {

            "rel": "self",

            "href": "http://ords.server/ords/db/patrick/patmod/dual/"

        },

        {

            "rel": "describedby",

            "href": "http://ords.server/ords/db/patrick/metadata-catalog/patmod/dual/"

        }

    ]

}

I understand that this is due to ORDS not knowing about the reverse-proxy taking place down-stream.

I've implemented a solution in nginx using ngx_http_sub_module module to rewrite the contents of the response on the fly (ie convert every occurrence http://ords to https://ords).

   location /ords {

      sub_filter_types       application/json;

      sub_filter             'http://ords.lfuat.net:8443'  'https://ords.lfuat.net:8443';

      sub_filter_once        off;

Is there a better way, maybe to either force these links to be created relative to current URL?  Or somehow specify the base URL to be https://ords.server?

Message was edited by: Patrick Jolliffe

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 8 2018
Added on Sep 27 2018
5 comments
1,632 views