Error (JSON 404): <!DOCTYPE HTML PUBLIC "-//IETF/ - vmc

When I run "vmc info", I get an error : Error (JSON 404):
cloud#rest:~/cloudfoundry/.deployments/rest/log$ vmc info -t
>>>
REQUEST: get http://api.mwt.needforspeed.info/info
RESPONSE_HEADERS:
content_length : 239
date : Thu, 11 Oct 2012 07:32:17 GMT
content_type : text/html; charset=iso-8859-1
content_encoding : gzip
server : Apache/2.2.22 (Ubuntu)
vary : Accept-Encoding
RESPONSE: [404]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /info was not found on this server.</p>
<hr>
<address>Apache/2.2.22 (Ubuntu) Server at api.mwt.needforspeed.info Port 80</address>
</body></html>
<<<
Error (JSON 404): <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /info was not found on this server.</p>
<hr>
<address>Apache/2.2.22 (Ubuntu) Server at api.mwt.needforspeed.info Port 80</address>
</body></html>

It looks like you have apache webserver running on port 80.
If you install cloudfoundry to a plain vanilla Ubuntu, it will install nginx as a webserver.
So first stop your apache, normally with:
sudo /etc/init.d/apache2 stop
and than check that your nginx (router in cloudfoundry's term) is running:
source ~/.cloudfoundry_deployment_local
~/cloudfoundry/vcap/dev_setup/bin/vcap_dev -n rest status router
please note that you need the extra -n rest parameter as it seems that you didn't use the default development name: dev_box

Related

s3fs: How to mount S3 buckets on AWS EC2 instances behind proxy, using IMDS v2

We are having some trouble to mount an AWS S3 bucket (using s3fs v1.90) into an AWS EC2 instance which:
is running Ubuntu 18.04
requires IMDS v2 session tokens
is behind a proxy
The HTTP response code returned by the curl lib is "417 - Expectation Failed" (more details below). I found some hints on the www that the 417 error might relate to our proxy config, see:
HTTP POST Returns Error: 417 "Expectation Failed."
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019LuWSAU
This makes me believe that our NO_PROXY config is not being picked up by s3fs, but I'm really not sure...
Anyway, this is what we've tried to do in order to mount the bucket:
sudo s3fs SOME_BUCKET ./mnt-s3/ -o iam_role=SOME_ROLE,url=https://s3.eu-central-1.amazonaws.com,endpoint=eu-central-1,allow_other,uid=1000,gid=1000,mp_umask=007,use_cache=/tmp/s3foldercache,dbglevel=debug -f
This is the output:
2021-09-08T12:36:27.681Z [INF] curl.cpp:CheckIAMCredentialUpdate(1826): IAM Access Token refreshing...
2021-09-08T12:36:27.681Z [INF] curl.cpp:GetIAMCredentials(3068): [IAM role=SOME_ROLE]
2021-09-08T12:36:27.681Z [DBG] curl_handlerpool.cpp:GetHandler(81): Get handler from pool: rest = 31
2021-09-08T12:36:27.681Z [DBG] curl.cpp:RequestPerform(2509): connecting to URL http://169.254.169.254/latest/api/token
2021-09-08T12:36:27.682Z [ERR] curl.cpp:RequestPerform(2622): HTTP response code 417, returning EIO. Body Text: <?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>417 - Expectation Failed</title>
</head>
<body>
<h1>417 - Expectation Failed</h1>
</body>
</html>
2021-09-08T12:36:27.682Z [ERR] curl.cpp:GetIAMCredentials(3105): AWS IMDSv2 token retrieval failed: -5
2021-09-08T12:36:27.682Z [DBG] curl.cpp:RequestPerform(2509): connecting to URL http://169.254.169.254/latest/meta-data/iam/security-credentials/SOME_ROLE
2021-09-08T12:36:27.684Z [ERR] curl.cpp:RequestPerform(2622): HTTP response code 401, returning EIO. Body Text: <?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>401 - Unauthorized</title>
</head>
<body>
<h1>401 - Unauthorized</h1>
</body>
</html>
2021-09-08T12:36:27.684Z [ERR] curl.cpp:CheckIAMCredentialUpdate(1830): IAM Access Token refresh failed
2021-09-08T12:36:27.684Z [DBG] curl_handlerpool.cpp:ReturnHandler(103): Return handler to pool
2021-09-08T12:36:27.684Z [INF] curl_handlerpool.cpp:ReturnHandler(110): Pool full: destroy the oldest handler
2021-09-08T12:36:27.685Z [CRT] s3fs.cpp:s3fs_check_service(3520): Failed to check IAM role name(SOME_ROLE).
2021-09-08T12:36:27.685Z [ERR] s3fs.cpp:s3fs_exit_fuseloop(3372): Exiting FUSE event loop due to errors
When running curl directly, though, we do receive a valid IMDS v2 token:
$ curl -v -X PUT -H "X-aws-ec2-metadata-token-ttl-seconds: 21600" http://169.254.169.254/latest/api/token
* Trying 169.254.169.254...
* TCP_NODELAY set
* Connected to 169.254.169.254 (169.254.169.254) port 80 (#0)
> PUT /latest/api/token HTTP/1.1
> Host: 169.254.169.254
> User-Agent: curl/7.58.0
> Accept: */*
> X-aws-ec2-metadata-token-ttl-seconds: 21600
>
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Content-Length: 56
< Content-Type: text/plain
< Date: Wed, 08 Sep 2021 13:14:02 GMT
< X-Aws-Ec2-Metadata-Token-Ttl-Seconds: 21600
< Connection: close
< Server: EC2ws
<
* Closing connection 0
SOME_TOKEN
Finally, this is our proxy config (defined by environment variables):
$ echo $HTTP_PROXY
<SOME_HOST>:<SOME_PORT>
$ echo $NO_PROXY
169.254.169.254,*.eu-central-1.amazonaws.com
So, my best guess is that s3fs might be ignoring the NO_PROXY variable, trying to use our proxy when asking local IP 169.254.169.254 for a new token.
A fix for this is being worked on in https://github.com/s3fs-fuse/s3fs-fuse/pull/1766

apache 301 redirect can i hide url from message

I have set 301 redirection for certain URL and I don't want this message
is there any way to remove URL from this message or just set custom message.
which is showing in response of curl
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved here.</p>
<hr>
<address>Apache/2.4.29 (Ubuntu) Server at x.x.x.x Port 80</address>
</body></html>
Edit /etc/apache2/conf-available/security.conf and set:
ServerTokens Prod
ServerSignature Off

Arduino esp8266 device gets Bad Request error from apache server while making request from

I am sending post request from my arduino device to my hosted server it gives me 400 Bad request error.
Same code runs well in my localhost but not working on Hosted server.
My arduino code if give below.
void callApi(String ID,String path,int comm,String message,int isResponseNeeded) {
String serverPath="www.xyz.com";
String data = "{" ;
data = data + "\"id\": \""+ID+"\"," ;
data = data + "\"version\": \""+VERSION+"\"," ;
data = data + "\"command\": \""+comm+"\"," ;
data = data + "\"message\": \""+message+"\"" ;
data = data + "}" ;
Serial.print("Send data...on=>");
Serial.println(path);
if (wifiClient.connect(serverPath,80)) {
Serial.println(data);
wifiClient.println("POST /abc/xyz HTTP/1.1");
wifiClient.println("Content-Type: application/json");
wifiClient.print("Host: ");
wifiClient.println(serverPath);
wifiClient.print("Content-Length: ");
wifiClient.println(data.length());
wifiClient.print("\n");
wifiClient.print(data);
wifiClient.print("\n");
Serial.println("Data sent...Reading response..");
if(isResponseNeeded>0){
unsigned long timeout = millis();
while (wifiClient.available() == 0) {
if (millis() - timeout > 10000) {
Serial.println(">>> Client Timeout !");
break;
}
}
String response;
while(wifiClient.available()){
String line = wifiClient.readStringUntil('\n');
response=line;
Serial.println(response);
}
Serial.println(response.length());
}
out put of this code.
{"id": "_60_1_94_f_a9_3c_","version": "1.10","command": "0","message": ""}
Data sent...Reading response..
HTTP/1.1 400 Bad Request
Date: Sat, 20 May 2017 05:13:41 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 324
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at ubuntu-512mb-nyc2-01.localdomain Port 80</address>
</body></html>
===========================================================
And one one more thing i have observed that. it runs GET request fine. only it cause issue while making POST request on my hosted server.
I guess that API service requires POST content and body to be application/x-www-form-urlencoded encoded.
application/x-www-form-urlencoded or multipart/form-data?

wcf service doesn't allow POST

I'm quite new to webervices in general and am getting stuck in (I think) configuring IIS and the webservice itself.
I created a wcf webservice in MVS 2010 and hosted it on IIS7.5 on windows 7.
I use soapUI 4.5.0 to post a message generated from the same wsdl description I created the webservice contract with. Issue is that I get 405 due to the fact that http POST not seems to be supported by the webservice or webserver.
Even though I had the idea the error I get would be sufficient to solve my problem, my lack of knowledge about IIS and webservices makes I can't find the right solution.
Below as much information as I could think of. Hope it is of any help and someone can guide me in the right direction.
Configurations made in IIS:
Authorization rule: allow, all users
Directory browsing: enabled
Handler mappings: features permissions: read, script and execute
Handler mappings: added *.wsdl -> ProtocolSupportModule -> GET, HEAD, OPTIONS, TRACE, POST
Application pools: added entry with identity NetworkService using
.net fw 4.0
This is the message sent:
RAW:
POST http: x.x.x.x:21378/ HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: application/soap+xml;charset=UTF-8;action="/BootNotification"
XML:
<soap:Envelope xmlns:soap="org/2003/05/soap-envelope" xmlns:ns="urn://Ocpp/Cs/2012/02/">
<soap:Header/>
<soap:Body>
<ns:bootNotificationResponse>
<ns:status>Accepted</ns:status>
<ns:currentTime>${now}</ns:currentTime>
<ns:heartbeatInterval>900</ns:heartbeatInterval>
</ns:bootNotificationResponse>
</soap:Body>
</soap:Envelope>
This is the result returned:
I truncated it to limit the size of this post.
RAW:
HTTP/1.1 405 Method Not Allowed
Cache-Control: private
Allow: GET, HEAD, OPTIONS, TRACE
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Thu, 07 Jun 2012 07:58:09 GMT
Content-Length: 5611
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns=".org/1999/xhtml">
<head>
<title>IIS 7.5 Detailed Error - 405.0 - Method Not Allowed</title>
<style type="text/css">
...
...
...
<div class="content-container">
<fieldset><legend>Most likely causes:</legend>
<ul> <li>The request sent to the Web server used an HTTP verb that is not allowed by the module configured to handle the request.</li> <li>A request was sent to the server that contained an invalid HTTP verb.</li> <li>The request is for static content and contains an HTTP verb other than GET or HEAD.</li> <li>A request was sent to a virtual directory using the HTTP verb POST and the default document is a static file that does not support HTTP verbs other than GET or HEAD.</li> </ul>
</fieldset>
</div>
<div class="content-container">
<fieldset><legend>Things you can try:</legend>
<ul> <li>Verify the list of verbs enabled for the module handler this request was sent to, and ensure that this verb should be allowed for the Web site.</li> <li>Check the IIS log file to see which verb is not allowed for the request.</li> <li>Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click here. </li> </ul>
</fieldset>
</div>
<div class="content-container">
<fieldset><legend>Links and More Information</legend>
This error means that the request sent to the Web server contained an HTTP verb that is not allowed by the configured module handler for the request.
<p>View more information »</p>
</fieldset>
</div>
</div>
</body>
</html>
XML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ".org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns=".org/1999/xhtml">
<head>
<title>IIS 7.5 Detailed Error - 405.0 - Method Not Allowed</title>
<style type="text/css">
...
</head>
<body>
<div id="header"><h1>Server Error in Application "SHENZIWEBSERVICEDEPLOYED"</h1></div>
<div id="server_version"><p>Internet Information Services 7.5</p></div>
<div id="content">
<div class="content-container">
<fieldset><legend>Error Summary</legend>
<h2>HTTP Error 405.0 - Method Not Allowed</h2>
<h3>The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.</h3>
</fieldset>
</div>
<div class="content-container">
...
</div>
<div class="content-container">
<fieldset><legend>Most likely causes:</legend>
<ul> <li>The request sent to the Web server used an HTTP verb that is not allowed by the module configured to handle the request.</li> <li>A request was sent to the server that contained an invalid HTTP verb.</li> <li>The request is for static content and contains an HTTP verb other than GET or HEAD.</li> <li>A request was sent to a virtual directory using the HTTP verb POST and the default document is a static file that does not support HTTP verbs other than GET or HEAD.</li> </ul>
</fieldset>
</div>
<div class="content-container">
<fieldset><legend>Things you can try:</legend>
<ul> <li>Verify the list of verbs enabled for the module handler this request was sent to, and ensure that this verb should be allowed for the Web site.</li> <li>Check the IIS log file to see which verb is not allowed for the request.</li> <li>Create a tracing rule to track failed requests for this HTTP status code. For more information about creating a tracing rule for failed requests, click here. </li> </ul>
</fieldset>
</div>
<div class="content-container">
<fieldset><legend>Links and More Information</legend>
This error means that the request sent to the Web server contained an HTTP verb that is not allowed by the configured module handler for the request.
<p>View more information »</p>
</fieldset>
</div>
</div>
</body>
</html>
This is part of the generated servicecontract (wsdl /language:CS /serverInterface
// CODEGEN: The optional WSDL extension element 'PolicyReference' from namespace 'http://schemas.xmlsoap.org/ws/2004/09/policy' was not handled.
[ServiceContract(Name = "CentralSystemServiceSoap", Namespace = "urn://Ocpp/Cs/2010/08/")]
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
[System.Web.Services.WebServiceBindingAttribute(Name="CentralSystemServiceSoap", Namespace="urn://Ocpp/Cs/2010/08/")]
public interface ICentralSystemServiceSoap {
/// <remarks/>
[OperationContract]
[System.Web.Services.Protocols.SoapHeaderAttribute("chargeBoxIdentity")]
[System.Web.Services.WebMethodAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("/BootNotification", RequestElementName = "bootNotificationRequest", RequestNamespace = "urn://Ocpp/Cs/2010/08/", ResponseElementName = "bootNotificationResponse", ResponseNamespace = "urn://Ocpp/Cs/2010/08/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("status")]
RegistrationStatus BootNotification(string chargePointVendor, string chargePointModel, string chargePointSerialNumber, string chargeBoxSerialNumber, string firmwareVersion, string iccid, string imsi, string meterType, string meterSerialNumber, out System.DateTime currentTime, [System.Xml.Serialization.XmlIgnoreAttribute()] out bool currentTimeSpecified, out int heartbeatInterval, [System.Xml.Serialization.XmlIgnoreAttribute()] out bool heartbeatIntervalSpecified);
I didn't understand how your service is built and what you have done there, but from my experience, this is a simple way to create a wcf RESTful service that supports POST requests:
http://www.codeproject.com/Articles/201901/CREATE-RESTful-WCF-Service-API-Using-POST-Step-By
Update according to the comments:
try using that:
[OperationContract]
[WebInvoke(Method = "POST")]
[System.Web.Services.Protocols.SoapHeaderAttribute("chargeBoxIdentity")]
[System.Web.Services.WebMethodAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("/BootNotification", RequestElementName = "bootNotificationRequest", RequestNamespace = "urn://Ocpp/Cs/2010/08/", ResponseElementName = "bootNotificationResponse", ResponseNamespace = "urn://Ocpp/Cs/2010/08/", Use = System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
[return: System.Xml.Serialization.XmlElementAttribute("status")]
RegistrationStatus BootNotification(string chargePointVendor, string chargePointModel, string chargePointSerialNumber, string chargeBoxSerialNumber, string firmwareVersion, string iccid, string imsi, string meterType, string meterSerialNumber, out System.DateTime currentTime, [System.Xml.Serialization.XmlIgnoreAttribute()] out bool currentTimeSpecified, out int heartbeatInterval, [System.Xml.Serialization.XmlIgnoreAttribute()] out bool heartbeatIntervalSpecified);
UPDATE
try doing that:
On IIS 7.5 -> YourWebsite -> Handler Mappings
Choose "Add module mapping" option on the right side of the panel
In "Request path" field enter *.wsdl
In "Module" field enter "ProtocolSupportModule"
Click on "Request restrictions" and go to Verbs tab
Enter POST verb
Save changes

noname attachment in my gmail inbox

While using Rails ActionMailer with Multipart Emails I created both:
approve_trade_email.html.erb
AND
approve_trade_email.text.erb
I do receive a well HTML formatted email in my Mail client (Mac OSX) but when checking my Gmail account for the same email I got an empty body with a noname attachement with the multiparts inside?
Help?
Why do I get this in Gmail?
thx
Joel
HERE THE NONAME ATTACHEMENT IN GMAIL:
----==_mimepart_4eab3a61bb3a8_10583ff27b4e363c43018
Date: Sat, 29 Oct 2011 01:27:29 +0200
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Content-ID: <4eab3a61bc857_10583ff27b4e363c43191#joel-maranhaos-macbook-pro.local.mail>
Do not to forget to make a donation on our Site: /home/index?path_only=false
----==_mimepart_4eab3a61bb3a8_10583ff27b4e363c43018
Date: Sat, 29 Oct 2011 01:27:29 +0200
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Content-ID: <4eab3a61bd5fa_10583ff27b4e363c432cb#joel-maranhaos-macbook-pro.local.mail>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link href="/assets/powerplants.css" media="screen" rel="stylesheet" type="text/css" />
</head>
<body id="email">
<p><b>Do not to forget to make a donation on our Site.</b></p>
</body>
</html>
----==_mimepart_4eab3a61bb3a8_10583ff27b4e363c43018--
I got the same problem and found the solution:
It's a bug in the old ActionMailer API of Rails 3, which does not include the multipart boundary definition in mail header.
see: https://github.com/rails/rails/pull/3090
You just have to use the new API (using the mail method)
class UserMailer < ActionMailer::Base
default :from => "notifications#example.com"
def welcome_email(user)
#user = user
#url = "http://example.com/login"
mail(:to => user.email, :subject => "Welcome to My Awesome Site")
end
end