i want to write one config for multiple sites.
these sites domain will like : x.localhost, y.localhost
but occur some errors.
this is error message:
caddy_1 | 18/Jan/2018:09:33:43 +0000 [ERROR 0 /index.php] Primary script unknown
caddy_1 | 172.20.0.1 - - [18/Jan/2018:09:33:43 +0000] "GET /index.php HTTP/1.1" 404 40
caddy_1 | xxx.localhost
*.localhost:80 {
root /var/www/{hostonly}/public
fastcgi / php-fpm:9000 php {
index index.php
}
rewrite {
to {path} {path}/ /index.php?{query}
}
gzip
browse
log stdout
errors stdout
log / stdout {hostonly}
}
as pointed out by your comment what you are trying to do with your caddyfile is not possible.
You need to specify each host and its root directory explicitly.
Related
I'm trying to upload a custom logo using CMD_API_SKINS
Here is my full code using curl + bash:
#/bin/bash
# DA needs this path
mkdir -p /home/tmp
# Assume my logo file is already here:
default_logo_file_home="/home/tmp/logo.png"
# The logo file is set to nobody:nogroup
chown nobody:nogroup "${default_logo_file_home}"
## Setup query data for curl:
username="admin"
password="12321aa"
da_port="2222"
host_server="server.domain.com"
ssl="https"
skin_name="evolution"
command="CMD_API_SKINS"
data="action=upload_logo&file=${default_logo_file_home}&json=yes&name=${skin_name}&which=1"
method="POST"
curl --silent --request "${method}" --user "${username}":"${password}" --data "${data}" "${ssl}://${host_server}:${da_port}/${command}"
When debugging this API, I got an error like this:
text='An Error Occurred'
result='Cannot get mime-type for log<br>
It seems like DA is trying to parse and obtain the extension name for the file "logo.png" but it couldn't
Full error logs:
DirectAdmin 1.61.5
Accepting Connections on port 2222
Sockets::handshake - begin
Sockets::handshake - end
/CMD_API_SKINS
0: Accept: */*
1: Authorization: Basic bWF4aW93bng3OnhGVEVHe***jUSg/UTRTfVdHYW0+fWNURn5ATWN***HFbZGpMezlQZ***=
2: Content-Length: 75
3: Content-Type: application/x-www-form-urlencoded
4: Host: server.domain.com:2222
5: User-Agent: curl/7.75.0
Post string: action=upload_logo&file=/home/tmp/logo2.png&json=yes&name=evolution&which=2
auth.authenticated
User::deny_override:/CMD_API_SKINS: call_level=2, depth1: aborting due to do depth
User::deny_override:/CMD_DOMAIN: call_level=2, depth1: aborting due to do depth
User::deny_override:/CMD_DOMAIN: call_level=1, depth2: aborting due to do depth
Plugin::addHooks: start
Plugin::addHooks: end
Command::doCommand(/CMD_API_SKINS)
cannot get mime type for log
Dynamic(api=1, error=1):
text='An Error Occurred'
result='Cannot get mime-type for log<br>
'
Command::doCommand(/CMD_API_SKINS) : finished
Command::run: finished /CMD_API_SKINS
I also try to encode the query like this but still got the same error
default_logo_file_home="%2Fhome%2Ftmp%2Flogo%2Epng"
data="action=upload%5Flogo&file=${default_logo_file_home}&json=yes&name=${skin_name}&which=%31"
Is there any explanations what is going on here? Is it possible to upload a logo using this API ?
Ok, I found the trick which is not documented anywhere. The uploaded file need to have a random string append to it. So I changed this:
default_logo_file_home="/home/tmp/logo.png"
into this:
RANDOM_STR="EbYIES"
default_logo_file_home="/home/tmp/logo.png${RANDOM_STR}"
Now it's working perfectly
I have an MVC6 Beta8 app that works locally. However when I publish it to Azure and open a home page, it return Error 500 "The page cannot be displayed because an internal server error has occurred.".
I enable the logs, but can only see kudu logs and http raw logs
2015-10-16 07:38:48 RENT-A-BIKE GET / X-ARR-LOG-ID=3c27af78-3874-4482-ac68-db29581070c1 80 - 112.207.250.32 Mozilla/5.0+(Windows+NT+10.0;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/46.0.2490.71+Safari/537.36 .AspNet.Microsoft.AspNet.Identity.Application=CfDJ8HSojZD46JRKpzcRvF66TcKzVHMrCLJRTTbz0MjK8rYaNUpfZzWwtz9EclfXXiMRUJ86IxNB_tWT5UhG03TptxP2tAXaedN0W1bQsMPhoeZR_OUrN5T0JeKZ8YAyqQkSfMmJo2rSphQFPfor7ztnbhs7vXaL0tYmsdflHAaRJH0nWs05vWuDfBkVnf7VofdoK5pICbz_QZ-HyNiH1dBzbl7CKvnzrpU7Erz4_hM4FPpAgY3hVRSuLuSYq8s9xnFNeLXI52u0DUU7GTwNYXZ946_wvjnIx706R6m4rh1c4__fLDNR6x2kPPHwWzKyftbhI3ETToJjAVtmNglY0WG9hCfZvZ_V_iCPWNmowfeU3YZ2Ux1lcDaHzr9o1o0T5ounqTzMqs_HzflN08-o7-xYF7BaqTOSjuScIWdpYDpXdzi7GAP3Hm7JPC3BG4A2GCoMjJpPDMDz6Aof9P0Td0EFB6XafDtduMewIZxf8-bGykUqoCgCb2i0dO21PFU-qkcg9kJ0LCm0kGdLERsEFLy4_a2X5vEBiyWIAlYu1JCb95l0FW87TcsMe1HwvsvubS4OkyIcKEo4UyX61AGPoRbf8OjXVvzYedG53mYdFVwsp2UARwmkGOqalp2ljGXYNCFtFkHc84ggj6XAvnnnvDCJDRAzABsNxm-b8mXtFEhgBKdzpS8Yn0egmHQNhDGP-hJy2hF-QJl8LnxjEpXg4yFtUaod54Y1_mopW11rkoWdz6aM4prIOf09TrG4NL4Y_1Ohgw;+_ga=GA1.3.68280290.1444933317;+ARRAffinity=e3c351936b5fcfb74e537a7dc58aebd6a3183747ae4ea853fe04b8e76e10ac5d - rent-a-bike.azurewebsites.net 500 19 183 466 1727 251
2015-10-16 07:38:48 RENT-A-BIKE GET /favicon.ico X-ARR-LOG-ID=5aaf9cc0-3594-4751-8571-197cc8465cef 80 - 112.207.250.32 Mozilla/5.0+(Windows+NT+10.0;+WOW64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/46.0.2490.71+Safari/537.36 .AspNet.Microsoft.AspNet.Identity.Application=CfDJ8HSojZD46JRKpzcRvF66TcKzVHMrCLJRTTbz0MjK8rYaNUpfZzWwtz9EclfXXiMRUJ86IxNB_tWT5UhG03TptxP2tAXaedN0W1bQsMPhoeZR_OUrN5T0JeKZ8YAyqQkSfMmJo2rSphQFPfor7ztnbhs7vXaL0tYmsdflHAaRJH0nWs05vWuDfBkVnf7VofdoK5pICbz_QZ-HyNiH1dBzbl7CKvnzrpU7Erz4_hM4FPpAgY3hVRSuLuSYq8s9xnFNeLXI52u0DUU7GTwNYXZ946_wvjnIx706R6m4rh1c4__fLDNR6x2kPPHwWzKyftbhI3ETToJjAVtmNglY0WG9hCfZvZ_V_iCPWNmowfeU3YZ2Ux1lcDaHzr9o1o0T5ounqTzMqs_HzflN08-o7-xYF7BaqTOSjuScIWdpYDpXdzi7GAP3Hm7JPC3BG4A2GCoMjJpPDMDz6Aof9P0Td0EFB6XafDtduMewIZxf8-bGykUqoCgCb2i0dO21PFU-qkcg9kJ0LCm0kGdLERsEFLy4_a2X5vEBiyWIAlYu1JCb95l0FW87TcsMe1HwvsvubS4OkyIcKEo4UyX61AGPoRbf8OjXVvzYedG53mYdFVwsp2UARwmkGOqalp2ljGXYNCFtFkHc84ggj6XAvnnnvDCJDRAzABsNxm-b8mXtFEhgBKdzpS8Yn0egmHQNhDGP-hJy2hF-QJl8LnxjEpXg4yFtUaod54Y1_mopW11rkoWdz6aM4prIOf09TrG4NL4Y_1Ohgw;+_ga=GA1.3.68280290.1444933317;+ARRAffinity=e3c351936b5fcfb74e537a7dc58aebd6a3183747ae4ea853fe04b8e76e10ac5d http://rent-a-bike.azurewebsites.net/ rent-a-bike.azurewebsites.net 500 19 183 466 1696 31
I also tried to disable custom errors in web.config, but it doesn't work (and as I understand starting from Beta8 is not supposed to work).
How can I troubleshoot this problem to see an actual error that occurred?
After I enabled "Detailed Error Messages" is Azure web app configuration, I was able to see DetailedErrors folder in Log Files directory that had a number of .html files with error details.
For that detailed errors begins appear in DetailedErrors folder in Log Files directory - restart your application in Azure.
In project.json file, for the web command specify the environment parameter = development
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel --ASPNET_ENV development",
}
In the Startup.cs file, in Configure you should have:
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
This means that when you run in other hosting environment that development, the Error page will be displayed instead the DeveloperExceptionPage.
I have an "upload" directory where users can upload confidential files (jpg, png, pdf). Each user gets assigned a folder inside upload, ex: /001/, /002/, ..., /999/, etc.
I want these files to be accessible only through SFTP, so the url http://example.com/upload/259/image.jpg should return a 403 error message.
I tried many variations, but still the files can be accessed through the url.
location ~ /upload/\.(jpe?g|png|gif|ico)$ {
deny all;
return 403;
}
Any thoughts?
You still need to match that part: '/259/image'
This should work:
location ~ /upload/.*\.(jpe?g|png|gif|ico)$ {
deny all;
return 403;
}
If access to /upload is only via sftp, then this is all you should need:
location ^~ /download/ {return 403;}
By skipping the regex cycle with ^~ you'll improve performance. Also your configuration will scale with fewer problems by not using a regex location. A prefix location can go anywhere, but not a regex location. The first regex match will be used which can lead to confusion down the road.
Hi I looking for some configuration or flag that allows me to silence the requested pages.
When I run python cherrypy_app.py and I join to the 127.0.0.1:8080 in the console where I start the cherrypy app show me
127.0.0.1 - - [09/Oct/2014:19:10:35] "GET / HTTP/1.1" 200 1512 "" "Mozilla/5.0 ..."
127.0.0.1 - - [09/Oct/2014:19:10:35] "GET /static/css/style.css HTTP/1.1" 200 88 "http://127.0.0.1:8080/" "Mozilla/5.0 ..."
127.0.0.1 - - [09/Oct/2014:19:10:36] "GET /favicon.ico HTTP/1.1" 200 1406 "" "Mozilla/5.0 ..."
I do not want to show this info. It is possible?
I as far as I remember in my first attempts with CherryPy I had the same desire. So here's a little more to say besides turning off the stdout logging per se.
CherryPy has some predefined environments: staging, production, embedded, test_suite that are defined here. Each environment has its set of configuration. So while developing stdout logging is in fact quite helpful, whereas in production environment it makes no sense. Setting the environment according to the deployment is the correct way to deal configuration in CherryPy.
In your particular case the stdout logging is controlled by log.screen. It is already disabled in production environment.
Here's the example, but note that setting environment inside your application isn't the best idea. You're better use cherryd's --environment for it instead.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import cherrypy
config = {
'global' : {
'server.socket_host' : '127.0.0.1',
'server.socket_port' : 8080,
'server.thread_pool' : 8,
# Doing it explicity isn't a recommended way
# 'log.screen' : False
}
}
class App:
#cherrypy.expose
def index(self):
return 'Logging example'
if __name__ == '__main__':
# Better use cherryd (http://cherrypy.readthedocs.org/en/latest/install.html#cherryd)
# for setting the environment outside the app
cherrypy.config.update({'environment' : 'production'})
cherrypy.quickstart(App(), '/', config)
I have a lighttpd server with website placed in /home/httpd/example.com/httpdocs and there I have a file called file.php. When I type http://en.example.com/file.php I would like to display file.php that is in default website directory (mentioned above).
So I used document-root described here:
http://redmine.lighttpd.net/wiki/1/Server.document-rootDetails
in this manner:
$HTTP["host"] =~ "en.example.com/file.php" {
server.document-root = "/home/httpd/example.com/httpdocs/"
}
But unfortunately when I type http://en.example.com/file.php into browser I get error 404. What I do wrong and how can I fix it to work?
In the case of the example URL http://en.example.com/file.php, the host is just en.example.com and not en.example.com/file.php (/file.php is the URL path). So try this:
$HTTP["host"] =~ "en.example.com" {
server.document-root = "/home/httpd/example.com/httpdocs/"
}