Closed lacosteque closed 2 years ago
@lacosteque
I found your JSON object is invalid. According to the docs, it works fine.
Let’s add a route to the prod app: POST always adds to the array end, so there’s no need for an index:
curl -X POST -d '{"match": {"uri": "/production/*"}, \
"action": {"pass": "applications/wiki-prod"}}' \
--unix-socket=/path/to/control.unit.sock \
http://localhost/config/routes/
Note it requires the type of entry corresponding to the request path like http://localhost/config/routes/
is array.
Of course, if you post a path like http://localhost/config/
, it returns the same error.
@lacosteque Could you show the result of sudo curl --unix-socket=/path/to/control.unit.sock http://localhost/config/routes/
command?
Note, that POST
in /config/routes/
will work only if the routes
object was previously configured as an array.
@lacosteque Could you show the result of
sudo curl --unix-socket=/path/to/control.unit.sock http://localhost/config/routes/
command?Note, that
POST
in/config/routes/
will work only if theroutes
object was previously configured as an array.
Yes, you are right. POST works, you need the correct configuration of the config.
Then maybe you can advise me on best practices and how to build the right config for my applications?
I have several projects on wordpress. At the moment the config for it is configured as follows...
{
"settings": {
"http": {
"header_read_timeout": 30,
"body_read_timeout": 30,
"send_timeout": 30,
"idle_timeout": 180,
"max_body_size": 16777216
}
},
"listeners": {
"127.0.0.1:8080": {
"pass": "routes/example.com",
"client_ip": {
"header": "X-Forwarded-For",
"recursive": true,
"source": ["127.0.0.1"]
}
}
},
"routes": {
"example.com": [
{
"match": {
"uri": ["*.php", "*.php/*", "/wp-admin/"]
},
"action": {
"pass": "applications/example.com/direct"
}
},
{
"action": {
"share": "/var/www/example.com/public/example.com$uri",
"fallback": {
"pass": "applications/example.com/index"
}
}
}
]
},
"applications": {
"example.com": {
"type": "php",
"user": "examplecomru",
"group": "examplecomru",
"processes": {
"max": 30,
"spare": 1
},
"options": {
"file": "/var/www/example.com/data/config/php.ini"
},
"isolation": {
"namespaces": {
"cgroup": true,
"credential": true,
"mount": true,
"network": false,
"pid": true,
"uname": true
}
},
"environment": {
"DB_NAME": "",
"DB_USER": "",
"DB_PASSWORD": "",
"DB_HOST": "",
"URL": ""
},
"targets": {
"direct": {
"root": "/var/www/example.com/public/example.com/"
},
"index": {
"root": "/var/www/example.com/public/example.com",
"script": "index.php"
}
}
}
}
}
For a few like this ...
"settings": {
"http": {
"header_read_timeout": 30,
"body_read_timeout": 30,
"send_timeout": 30,
"idle_timeout": 180,
"max_body_size": 16777216
}
},
"listeners": {
"127.0.0.1:8080": {
"pass": "routes/example.com",
"client_ip": {
"header": "X-Forwarded-For",
"recursive": true,
"source": ["127.0.0.1"]
}
},
"127.0.0.1:8081": {
"pass": "routes/example2.com",
"client_ip": {
"header": "X-Forwarded-For",
"recursive": true,
"source": ["127.0.0.1"]
}
}
},
"routes": {
"example.com": [
{
"match": {
"uri": ["*.php", "*.php/*", "/wp-admin/"]
},
"action": {
"pass": "applications/example.com/direct"
}
},
{
"action": {
"share": "/var/www/example.com/public/example.com$uri",
"fallback": {
"pass": "applications/example.com/index"
}
}
}
],
"example2.com": [
{
"match": {
"uri": ["*.php", "*.php/*", "/wp-admin/"]
},
"action": {
"pass": "applications/example2.com/direct"
}
},
{
"action": {
"share": "/var/www/example2.com/public/example2.com$uri",
"fallback": {
"pass": "applications/example2.com/index"
}
}
}
]
},
"applications": {
"example.com": {
"type": "php",
"user": "root",
"group": "root",
"processes": {
"max": 30,
"spare": 1
},
"options": {
"file": "/var/www/example.com/data/config/php.ini"
},
"isolation": {
"namespaces": {
"cgroup": true,
"credential": true,
"mount": true,
"network": false,
"pid": true,
"uname": true
}
},
"environment": {
"DB_NAME": "",
"DB_USER": "",
"DB_PASSWORD": "",
"DB_HOST": "",
"URL": ""
},
"targets": {
"direct": {
"root": "/var/www/example.com/public/example.com/"
},
"index": {
"root": "/var/www/example.com/public/example.com",
"script": "index.php"
}
}
},
"example2.com": {
"type": "php",
"user": "root",
"group": "root",
"processes": {
"max": 30,
"spare": 1
},
"options": {
"file": "/var/www/example2.com/data/config/php.ini"
},
"isolation": {
"namespaces": {
"cgroup": true,
"credential": true,
"mount": true,
"network": false,
"pid": true,
"uname": true
}
},
"environment": {
"DB_NAME": "",
"DB_USER": "",
"DB_PASSWORD": "",
"DB_HOST": "",
"URL": ""
},
"targets": {
"direct": {
"root": "/var/www/example2.com/public/example2.com/"
},
"index": {
"root": "/var/www/example2.com/public/example2.com",
"script": "index.php"
}
}
}
}
}
Is there any way to lighten them up through routes? To use 1 listener? If not, how in my case is it possible to add other apps via POST? Thanks
Hi Why doesn't Unit understand post request? For example I'm making a POST request from the manual
But the config doesn't update, but gives an error
$unitd --version