nextjs in docker proxy via apache2 is giving 502 proxy errors

Viewed 14

I have a nextjs application running in a docker. When I had the same docker image running locally and goto localhost:3000 everything runs perfectly.

I then deploy the image to the server and I have apache2 proxy passing to the site I get a broken landing page

I see I am getting errors like this

Request URL: http://example.com/_next/static/css/175964cd052c7c3f.css
Request Method: GET
Status Code: 502 Proxy Error

My apache setup is like this

<VirtualHost *:80>
        ServerName example.com
        ServerAlias  example.com

        ProxyPreserveHost On
        ProxyRequests Off
        ProxyVia On
        ProxyPass  /excluded !
        ProxyPass / http://127.0.0.1:3000 connectiontimeout=6000 timeout=6000
        ProxyPassReverse / http://127.0.0.1:3000

       CustomLog /var/log/apache2/mydomain.access.log combined
       ErrorLog /var/log/apache2/mydomain.error.log
</VirtualHost>

Any help would be appreciated

Thanks

1 Answers
<VirtualHost *:80>
    ServerName www.myservername.com
    ServerAlias myservername.com

    ErrorLog /var/www/myapp/log/error.log
    CustomLog /var/www/myapp/log/requests.log combined

    ProxyRequests on
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/
</VirtualHost>

It seems something was clashing. When I stripped it down to the above it works

Related