Configure NGINX reverse proxy for websites hosted on S3


I am working on hosting static websites on amazon S3. The structure of the website will be bucket-name / site-name / files.html . Now my problem is that the user can use his own domain to publish the website. For example: he owns a domain such as www.ABC.com and wants to host his site there.
I installed a reverse proxy server on an ec2 instance to proxy requests, that is, one hit www.ABC.com should see the contents from the S3 bucket or the domain name should point to the S3 bucket.
I know there are DNS changes and updates to CNAME and A records, but I also need to write RULES in the NGINX configuration to redirect the URL as I want.

This is a structure that I have, I don’t work, and I would like the experts to watch: I am currently publishing my sites on the sites.development.com/bucket-name/sitename subdomain.
This is my default.conf file after installing nginx.

  server { listen xx0.0:80; server_name xxxx; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; root /usr/local/nginx/html; index index.html; location / { proxy_pass http://development.mydomain.com:9585; include /etc/nginx/proxy_params; } } 

I am currently installing it on a development server whose URL is http://development.mydomain.com (this is an independent instance of ec2). My proxy server runs on a different instance of EC2 than http://development.mydomain.com .

I came up with some kind of structure based on suggestions from different sources.
It is he:

  server { listen 80; server_name xxxx; //This would be the name on which I have NGINX installed,right? set $host_without_www $host; //What would be the host?any host with www pointing to the site on S3? if ($host ~* www\.(.*)) { set $host_without_www $1; } location / { rewrite ^(.*)$ /$host_without_www$1 break; proxy_pass {{s3-bucket-url}}; } } 

I have no experience with NGINX and proxies and therefore have been stuck for some time.
Please share comments based on your experience and suggest a solution.
Thanks for attention.

0
php amazon-s3 amazon-web-services nginx bucket
source share

No one has answered this question yet.

See similar questions:

6
Complicated nginx rewrite rules for subdomains
one
Updating S3 folder name using AWS sdk for PHP

or similar:

954
Node.js + Nginx - What Now?
8
Express - req.ip returns 127.0.0.1
6
what is wrong with this configuration for nginx as a reverse proxy for node.js?
4
Configure Nginx Reverse Proxy
2
BUCKET's Multiple Website Hosting on Amazon S3
one
Django uWSGI Nginx
0
How to serve pages from another domain using Nginx
0
Nginx win server 2012 - proxy pass configuration
0
How to specify many proxy server paths in nginx

All Articles