I've containerized the next.js web application and hosted in aws ec-2. using nginx as proxy server

this is the only working page

/

not working for any other pages (paths),it throws 502 bad-gate-way

EX:

/etc

/slug/page

this is the nginx cofiguration

server { listen 80 default_server; location / { proxy_pass } 

}

how can I Forward all paths to a specific port?

6

1 Answer

server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; index index.html index.htm index.nginx-debian.html; server_name _; location / { # reverse proxy for next server proxy_pass proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; # we need to remove this 404 handling # because next's _next folder and own handling # try_files $uri $uri/ =404; } location ~ /.well-known { allow all } } 

I've add this nginx configuration, now it's working fine.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy