Help with convert NGINX conf to Caddy

Hi! I try to convert NGINX config to Caddy & need help with proxy with path rewrite

This is nginx.conf

server {
    listen 80;
    server_name mysite.ru;
    ssl off;
        client_max_body_size 64m;
    proxy_connect_timeout       600;
    proxy_send_timeout          600;
    proxy_read_timeout          600;
    send_timeout                600;
    location / {
        proxy_pass http://localhost:81; # existing instance
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    location /service/ucsregister {
    rewrite ^/service/ucsregister(.*) /ucs/register$1 break;
    proxy_pass http://localhost:1235;
    }
    location /service/ucscallback {
    rewrite ^/service/ucscallback(.*) /ucs/callback$1 break;
    proxy_pass http://localhost:1235;
    }

}

This is my try of Caddyfile variant. What solution is right?

mysite.ru {
proxy / localhost:81 # CRM on apache

    rewrite /service/ucsregister {
        r  (.*)
        to /ucs/register{1}
    }
    proxy /service/ucsregister http://localhost:1235
    rewrite /service/ucscallback {
        r  (.*)
        to /ucs/callback{1}
    }
    proxy /service/ucscallback http://localhost:1235

}

Looks good at a glance. You may wish to add the transparent preset for your proxy directive.

Are you having any problems?

What param need to add to transparent?
This is full finished config

mysite.ru {
        proxy / localhost:81   # CRM on apache

        rewrite /service/ucsregister {
            r  (.*)
            to /ucs/register{1}
        }
        proxy /ucs/register localhost:1235


        rewrite /service/ucscallback {
            r  (.*)
            to /ucs/callback{1}
        }
        proxy /ucs/callback localhost:1235


        rewrite /service/ucspreview {
            r  (.*)
            to /ucs/preview{1}
        }
        proxy /ucs/ucspreview localhost:1235


        rewrite /service/mandarincheck {
            r  (.*)
            to /mandarin/check{1}
        }
        proxy /mandarin/check localhost:1235


        rewrite /service/mandarinredirect {
            r  (.*)
            to /mandarin/redirect{1}
        }
        proxy /mandarin/redirect localhost:1235


        rewrite /service/scoristaview {
            r  (.*)
            to /scorista/view/solution{1}
        }
        proxy /scorista/view/solution localhost:6660


        proxy /static localhost:1235


        proxy /scoring/static localhost:6660
}

Have a look at the presets in the proxy docs for an explanation of how they work and what they do.

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