How to visit different project directory

1. Output of caddy version:

v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=

2. How I run Caddy:

a. System environment:

systemclt start caddy

b. Command:

Paste command here.

c. Service/unit/compose file:

[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target network-online.target
Requires=network-online.target

[Service]
Type=notify
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile --force
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE

[Install]
WantedBy=multi-user.target

d. My complete Caddy config:

(handle_log) {
	log {
		output file /etc/caddy/logs/caddy2.log
		level INFO
	}
}

(handle_errors) {
    handle_errors {
        respond "{http.error.status_code} {http.error.status_text}"
    }
}

www.tigerice.cn {

	encode gzip

        import handle_errors

        import handle_log

	route /merchant/* {
		uri strip_prefix /merchant

		file_server {
			root /opt/twomicro_v2/web/merchant

			browse

			disable_canonical_uris
		}
	}

	route /app/* {
		uri strip_prefix /app

		file_server {
			root /opt/twomicro_v2/web/app

			browse

			disable_canonical_uris
		}
	}

	file_server * {
		root /var/www/html
	}

        @nacos path /nacos /nacos*
        reverse_proxy @nacos {
            header_up Host {http.reverse_proxy.upstream.hostport}
            header_down Access-Control-Allow-Origin *
            header_down Access-Control-Allow-Methods GET,POST,OPTIONS
            header_down Access-Control-Allow-Headers X-Requested-With
            to http://127.0.0.1:8848        
        }

}

3. The problem I’m having:

how to visit different project directory.

curl -v https://www.tigerice.cn/app , it can browse app project.

curl -v https://www.tigerice.cn/merchant, it can browse merchant project.

how to config.

4. Error messages and/or full log output:

Paste logs/commands/output here.
USE THE PREVIEW PANE TO MAKE SURE IT LOOKS NICELY FORMATTED.

5. What I already tried:

6. Links to relevant resources:

i have solved it. here is my solution.

	@web_path1 path /merchant/*
	file_server @web_path1 {
		root /opt/twomicro_v2/web
	}

        @web_path2 path /torna*
        file_server @web_path2 {
                root /opt/twomicro_v2/web
        }

        @web_path3 path /dingding*
        file_server @web_path3 {
                root /opt/twomicro_v2/web
        }

        @web_path4 path /dist*
        file_server @web_path4 {
                root /opt/twomicro_v2/web
        }

This topic was automatically closed after 30 days. New replies are no longer allowed.