Skip to Main Content

APEX

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!

Nginx custom domain proxy server for Oracle Apex app not working properly

Mia GoNov 22 2024

I am using Nginx as proxy server for my Oracle APEX App. When I run my custom domain mycustomdomain.com my APEX app home page opens but I have 3 problems:

  1. First time opening in browser mycustomdomain.com I get mycustomdomain.com/ords/r/myapp/sample-charts/home. The second time I open it in the same browser it opens as mycustomdomain.com/home as I want it to be always and not just from the second time.

  2. When I click in my navigation bar in the app to go to other page then homepage that was first to open they open as mycustomdomain.com/ords/r/myapp/sample-charts/somepagename and not mycustomdomain.com/somepagename. Also when opening any of them, I get error Failed to load resource: the server responded with a status of 403 (Forbidden). When I run by hand in browsermycustomdomain.com/somepagename it works but there is also the same error 403.

  3. When I go back from any page to home page it does not take me to mycustomdomain.com/home it takes me to mycustomdomain.com/ords/r/myapp/sample-charts/home.

    Here is the code:

    #http server block(port 80) -Redirects to HTTPS

    server {
    listen 80;
    server_name mycustomdomain.com www.mycustomdomain.com;

    #Redirect all HTTP traffic to HTTPS
    return 301 https://$host$request_uri;
    }

    #https server block(port 443)
    server{
    listen 443 ssl;
    server_name mycustomdomain.com www.mycustomdomain.com;

    ssl_certificate /etc/ssl/mycustomdomain/SSLCertificate/hm_certificate.crt;
    ssl_certificate_key /etc/ssl/mycustomdomain/SSLCertificate/hm_privatekey.key;
    ssl_trusted_certificate /etc/ssl/mycustomdomain/SSLCertificate/hm_cabundle.ca-bundle;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384';
    ssl_prefer_server_ciphers off;

    #Document root and other settings
    root /var/www/html;
    index index.html index.htm index.php;

    #Security headers
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
    add_header X-Content-Type-Options nosniff;
    add_header X-Frame-Options SAMEORIGIN;
    add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0" always;
    add_header Pragma "no-cache" always;

    #Proxy to Oracle APEX app

    location = / {
    rewrite ^/$ /home permanent;
    }

    location /home {

    proxy_pass https://myinstance0123.adb.eu-milan-1.oraclecloudapps.com/ords/r/myapp/sample-charts/home;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Cookie $http_cookie;
    proxy_cookie_path /ords/ /;
    proxy_redirect https://myinstance0123.adb.eu-milan-1.oraclecloudapps.com/ https://mycustomdomain.com/;
    }

    location / {

    rewrite ^/([^/]+)$ /ords/r/myapp/sample-charts/$1 break;

    proxy_pass https://myinstance0123.adb.eu-milan-1.oraclecloudapps.com;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Cookie $http_cookie;
    proxy_pass_request_headers on;
    proxy_cookie_path /ords/ /;
    proxy_redirect https://myinstance0123.adb.eu-milan-1.oraclecloudapps.com/ https://mycustomdomain.com/;
    }

    location /i/{

    proxy_pass https://myinstance0123.adb.eu-milan-1.oraclecloudapps.com/i/;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;

    }

    }

Comments
Post Details
Added on Nov 22 2024
1 comment
419 views