Redirect A record to localhost:8080 with nginx

OS type and version Ubuntu 22.04
Webmin version 2.111
Virtualmin version 7.10.0
Related packages SUGGESTED

I’m hosting e.g. domain. com on my VPS using Virtualmin.
I have a game panel on the same VPS. The game panel has a GUI that listen to port 8080.
How can I setup nginx in order to go to IP:8080 whenever I go for panel.
I tried to add the following but I’m seeing the same default page I have on

server {
    server_name panel.;

    client_max_body_size 100M;
    proxy_request_buffering off;
    proxy_buffering off;
    proxy_pass_request_body on;

    location / {
        proxy_set_header        Host $host;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        X-Forwarded-For $remote_addr;
        proxy_set_header        Upgrade $http_upgrade;
        proxy_set_header        Connection $http_connection;
        proxy_set_header        X-AMP-Scheme $scheme;

Space typo on domain name as I can’t post with more than 2 urls.

I’ve figured it out on my own. I had to create the subdomain and then use the lines I used in the original post. The config location is /etc/nginx/sites-available.

You can proxy from any path, not just /. So, it’s fine to put it on a subdomain, but it’s also possible to have a bunch of apps running on other paths, e.g. /app1 and /app2.

Note that “redirect” is a concept distinct from proxying. You want proxying, a redirect to localhost could never work outside of the system itself. (A redirect tells the browser to load another URL. Proxying makes the request to the backend service and then hands the results back to the browser.)

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.