I am using AWS Lightsail and Apache to host a web app on a Static IP. I now want to move that web app to a custom domain that I own, such that when I enter that domain I am taken to my web app, with the domain in the address bar (rather than the static IP).
To achieve this, I implemented a reverse proxy using Nginx, however I still find that the address bar still shows the static IP. The script I am using for my reverse proxy is here:
server {
listen 8081;
server_name mydomain.org;
location / {
proxy_pass http://xx.xx.xx.xx/ops;
proxy_set_header 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_redirect http://xx.xx.xx.xx/ops http://mydomain.org/;
}
}
From what I assume, the Nginx service is working. I don't see any errors and sudo systemctl status nginx
returns Fine. I also have an A record on my Cloudflare DNS provider pointing the domain root (@) to my static IP on which the Nginx service is hosted (same IP as the web app). When I try curl -I http://mydomain.org
, I get:
HTTP/1.1 301 Moved Permanently
Date: Tue, 21 May 2024 11:42:22 GMT
Content-Type: text/html
Content-Length: 167
Connection: keep-alive
Cache-Control: max-age=3600
Expires: Tue, 21 May 2024 12:42:22 GMT
Location: http://xx.xx.xx.xx/ops
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=7TeZ5KZpOPdntdFuk0R63mg%2FLnb%2BOgp9GvOsby5O%2BfWU%2FG
G3VUkKe0WL1srgjseB6VpCh5QdWZCuj%2Ft5mcSE7QZjoDHDTzM6nF1tkGQVtWwwQdMciGor7OvI3aeVFH1u7xIsZ%2BohuM6cAA%3D%3D"}],"group":"cf-nel","max_
age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 88744d7e2ae44a41-SIN
alt-svc: h3=":443"; ma=86400
Potential reasons for this problem:
The web app is hosted on
http://xx.xx.xx.xx/ops
, while the static IP leads to a generic landing page.Something to do with the Open Preprint Service (I've checked their
config.php
but I don't think there was anything relevant).
Any help would be appreciated.