I have an app in the App Store that interects with a RESTful Rails app hosted on Heroku. I did the terrible mistake of hardcoding the API's base URL to myapp.heroku.com instead of using the top level domain.
I'm now in the process of migrating to a new server so I'm trying to see what are my options to make the transition seamless to my iPhone app users. I thought of creating a Rake app that redirects all the traffic from that heroku subdomain to my new server address, but then I read that HTTP 1.1 doesn't allow POST redirection (my API having several POST endpoints). I could always redirect my POST requests as GET ones, but that definitely doesn't feel right.
Is there any other option I might be missing? Is there any way Heroku would accept to change the A records of my subdomain to point to my new server IP?
I ended up doing as John said and change my API endpoint inside my app. To keep previous versions of the app working (which have the heroku subdomain hardcoded in them), I ended up writing this quick Sinatra app and replaced my original Heroku app with it:
require 'sinatra'
require 'mechanize'
API_BASE_URL = "http://newdomain.com"
get '/*' do |path|
url = URI("#{API_BASE_URL}/#{path}")
agent = Mechanize.new
agent.user_agent = request.user_agent
headers = {'AUTHORIZATION' => request.env['HTTP_AUTHORIZATION']}
page = agent.post(url, params, headers)
content_type :json
page.body
end
get '/*' do |path|
url = URI("#{API_BASE_URL}/#{path}")
agent = Mechanize.new
agent.user_agent = request.user_agent
headers = {'AUTHORIZATION' => request.env['HTTP_AUTHORIZATION']}
page = agent.get(url, params, nil, headers)
content_type :json
page.body
end
(this code could probably be reduced down to a single method)
They wouldn't update their DNS for you - *.heroku.com will be a wildcard DNS entry, they don't add a new subdomain each time a site is added.
It would seem the best solution would be to fix it properly. Attach the new domain to your existing application on Heroku, it will still be accessible on app.heroku.com and yourcustomdomain.com.
Then, update your iOS application to use the new customdomain for it's endpoint. Once it's all working, reduce the TTL on the DNS entry and then repoint it at your new server.
Related
Below issue was posted by me on https://github.com/XiaoFaye/WooCommerce.NET/issues/414 but since this may not be related at all to WooCommerce.Net but on a lowerlevel to Apache/Word/WooCommerc itself I am posting the same question here
I am really stuck with the famous error:
WebException: {"code":"woocommerce_rest_authentication_error","message":"Invalid signature - provided signature does not match.","data":{"status":401}}
FYI:
I have two wordpress instance running. One on my local machine and one on a remote server. The remote server is, as my local machine, in our company's LAN
I am running WAMP on both machines to run Apache and host Wordpress on port 80
The error ONLY occurs when trying to call the Rest api on the remote server. Connecting to the local rest api, the Rest Api/WooCommerceNet is working like a charm :-)
From my local browser I can login to the remote WooCommerce instance without any problem
On the remote server I have defined WP_SITEURL as 'http://[ip address]/webshop/ and WP_HOME as 'http://[ip address]/webshopin wp-config.php
Calling the api url (http://[ip address]/webshop/wp-json/wc/v3/) from my local browser works OK. I get the normal JSON response
Authentication is done through the WooCommerce.Net wrapper which only requires a consumer key, consumer secret and the api url. I am sure I am using the right consumer key and secret and the proper api url http://[ip address]/webshop/wp-json/wc/v3/ (see previous bullet)
I already played around with the authorizedHeader variable (true/false) when instantiating a WooCommerce RestApi but this has no effect
Is there anybody that can point me into the direction of a solution?
Your help will be much appreciated!
In my case, the problem was in my url adress. The URL Adress had two // begin wp-json
Url Before the solution: http://localhost:8080/wordpress//wp-json/wc/v3/
URL Now, and works ok: http://localhost:8080/wordpress/wp-json/wc/v3/
I use with this sentence.
RestAPI rest = new RestAPI(cUrlApi, Funciones.CK, Funciones.CS,false);
WCObject wc = new WCObject(rest);
var lstWooCategorias = await wc.Category.GetAll();
I hope my answer helps you.
Had the same issue. My fault was to define my url incorrect: http:// instead of https://.
I am currently working on a DotNetNuke website (07.03.02) and I am trying to migrate it to Azure. The website is working on my local machine with IIS.
I followed this tutorial to migrate the website : http://www.dnnsoftware.com/community-blog/cid/154975/moving-a-dnn-install-to-microsoft-azure-websites
So I created a new web application on Azure that will host the website files. I also created a new database on Azure, and I imported my DNN backup database.
I changed the connection strings in my web.config to use my Azure database, I uploaded the website folder on Azure.
Now if I try to browse my webapp using the link [sitename].azurewebsites.net, I get the following error :
DNN Error Domain Name Does Not Exist In The Database
DotNetNuke supports multiple websites from a single database/codebase.
It accomplishes this by converting the URL of the client browser
Request to a valid PortalID in the Portals database table. The
following steps describe the process:
Web Server Processing When a web server receives a Request from a
client browser, it compares the file name extension on the target URL
resource to its Application Extension Mappings defined in IIS. Based
on the corresponding match, IIS then sends the Request to the defined
Executable Path ( aspnet_asapi.dll in the case of ASP.NET Requests ).
The aspnet_isapi.dll engine processes the Request in an ordered series
of events beginning with Application_BeginRequest.
HttpModule.URLRewrite OnBeginRequest ( UrlRewriteModule.vb ) The
Request URL is parsed based on the "/" character A Domain Name is
constructed using each of the relevant parsed URL segments.
Examples:
URL: http://www.exemple.com/default.aspx = Domain Name: www.exemple.com
URL: http://209.75.24.131/default.aspx = Domain Name: 209.75.24.131
URL: http://localhost/DotNetNuke/default.aspx = Domain Name:
localhost/DotNetNuke URL:
http://www.exemple.com/virtualdirectory/default.aspx = Domain Name:
www.exemple.com/virtualdirectory URL:
http://www.exemple.com/directory/default.aspx = Domain Name:
www.exemple.com/directory
Using the Domain Name, the application queries the database ( Portals
table - PortalAlias field ) to locate a matching record.
Note: If there are multiple URLs which correspond to the same website
then the website alias field must contain each valid Domain Name in a
comma separated list.
Example:
URL: http://localhost/DotNetNuke/default.aspx URL:
http://MACHINENAME/DotNetNuke/default.aspx URL:
http://209.32.134.65/DotNetNuke/default.aspx PortalAlias:
localhost/DotNetNuke,MACHINENAME/DotNetNuke,209.32.134.65/DotNetNuke
Note: If you are installing the application to a remote server you
must modify the PortalAlias field value for the default record in the
Portals table according to the rules defined above.
So I inserted the Site Alias ([sitename].azurewebsites.net) record into the PortalAlias table as mentioned in the turorial.
Now when I try to reach the website [sitename].azurewebsites.net, I don't have the previous DNN error but it loads for a long time and then I got the following error :
www.[sitename].azurewebsites.net’s server DNS address could not be
found. DNS_PROBE_FINISHED_NXDOMAIN
After the load end, the URL curiously become https://www.[sitename].azurewebsites.net and the DNS error occur.
Is there something I need to change in Azure or in my web.config file ? Maybe there is something to configure in DotNetNuke or in the ASP version?
I don't get why my browser change the url and why this dns error occur (I have no issues with my local IIS server).
(I also tried by using the automatic portal alias transfer as mentioned in the tutorial but I got the same result : the alias is inserted in the database but I still have the NXdomain error)
Thank you for your help !
Etienne.
In your original post you have:
www.[sitename].azurewebsites.net’s server DNS address could not be found. DNS_PROBE_FINISHED_NXDOMAIN
Try to manually put the . (The full, http with colons, etc.) Sometimes the web browser will add the WWW automatically, thinking you wanted it (I hate when they do that). Azure doesn't know about the www subdomain, so that is why you are probably getting that error.
Edit: Oh, and the long load time is good - it means that azure compiled your site and you didn't get a compile error.
The fact that you get an error that comes from DNN is good news, and means that you have (probably) done the major work correctly.
Now, you need to get into your database and modify the PortalAlias table so that there is an alias for sitename.azurewebsites.net. (I'm assuming that the brackets around sitename are incorrect and "[sitename]" eeds to be replaced by the actual domain name for your site.)
I have a desktop application that is self hosting a NancyFX web server. Being a desktop application there is a requirement that we allow dynamic IP addresses so we have registered the url using the wildcard option with netsh, as so:
netsh http add urlacl url=http://+:1234/ user=Everyone
However when this application is run under a non-administrator account the following exception is thrown.
The Nancy self host was unable to start, as no namespace reservation existed for the provided url(s).
Please either enable UrlReservations.CreateAutomatically on the HostConfiguration provided to
the NancyHost, or create the reservations manually with the (elevated) command(s):
netsh http add urlacl url=http://192.168.1.90:1234/ user=Everyone
I have tried many combinations of wildcard registrations, all with the same result. I also looked at registering the wildcard when loading Nancy, but due to Nancy using Uri types this was not valid.
I was under the assumption that by using the wildcard registration I had registered any ip address to be used. But Nancy seems to need the specific ip address registered.
I would really appreciate if someone could tell my why the wildcard registration will not work with Nancy, or even better, how to make it work with Nancy.
An old question but if anyone runs into this, Nancy SelfHost allows you to create Url reservations automatically using the HostConfiguration object.
The Url is then reserved automatically on startup.
//Nancy configuration
HostConfiguration hostConfig = new HostConfiguration()
{
UrlReservations = new UrlReservations()
{
//create URL reservations automatically
CreateAutomatically = true
}
};
//Uri
Uri uri = new Uri("http://localhost:9999");
using (var host = new NancyHost(hostConfig, uri))
{
host.Start();
Console.WriteLine("Running self-hosted server ...");
Console.WriteLine("Press [Enter] to close the application.");
Console.ReadLine();
}
Hi I'm running into an issue where Symfony2 doesn't recognize the load balancer headers from Amazon AWS, which are need to determine if a request is SSL or not using the requires_channel: https security configuration.
By default Symfony2 $request->isSecure() looks for "X_FORWARDED_PROTO" but there's apparently no standard for this, and Amazon AWS load balancers use "HTTP_X_FORWARDED_PROTO".
I see the cookbook article for setting trusted proxies in config, but that's geared around whitelisting specific IP addresses and won't work with AWS, which generates dynamic IPs. Another feature, setting the framework config to include trust_proxy_headers: true is deprecated. This breaks my app by forcing endless redirects on the pages that require SSL-only.
You can now change the headers using setTrustedHeaderName(). This method allows you to change the four headers used throughout the file.
const HEADER_CLIENT_IP = 'client_ip'; // defaults 'X_FORWARDED_FOR'
const HEADER_CLIENT_HOST = 'client_host'; // defaults 'X_FORWARDED_HOST'
const HEADER_CLIENT_PROTO = 'client_proto'; // defaults 'X_FORWARDED_PROTO'
const HEADER_CLIENT_PORT = 'client_port'; // defaults 'X_FORWARDED_PORT'
The above, taken from the Request class indicate the keys available for use with the aforementioned method.
// $request is instance of HttpFoundation\Request;
$request->setTrustedHeaderName('client_proto', 'HTTP_X_FORWARDED_PROTO');
That said, at the time of writing, using "symfony/http-foundation": "2.5.*" the below code correctly determines whether or not the request is secure whilst behind an AWS Load Balancer.
// All IPs (*)
// $proxies = [$request->getClientIp()];
// Array of CIDR pools from load balancer
// EC2 -> Network & Security -> Load Balancers
// -> X -> Instances (tab) -> Availability Zones
// -> Subnet (column)
$proxies = ['172.x.x.0/20'];
$request->setTrustedProxies($proxies);
var_dump($request->isSecure()); // bool(true)
You're right the X_FORWARDED_PROTO header is hardcoded into HttpFoundation\Request while - as far as i know - overriding the request class in symfony is currently not possible.
There has been a discussion/RFC about this topic here and there is an open pull-request that solves this issue using a RequestFactory.
I am trying to send activation mail to the currently registered user.In mail body,I need to send a link like http://example.com/account/activation?username=d&email=g.Now, for debugging on local machine, I manually write it as localhost:30995/account/activation?username=d&email=g. But, when my port number changes, I need to rewrite it.
I tried another question
on this website,but, compiler gives error like url.action doesnot exist.
Please give me fresh solution as I am confused with that solution.
Use a Url.Action overload that takes a protocol parameter to generate your URLs:
Url.Action("Activation", "Account", new { username = "d", email = "g" }, "http")
This generates an absolute URL rather than a relative one. The protocol can be either "http" or "https". So this will return http://localhost:XXXXX/account/activation?username=d&email=g on your local machine, and http://example.com/account/activation?username=d&email=g on production.
In short, this will stick whatever domain you're hosting your app on in front of your URL; you can then change your hostname/port number/domain name as many times as you want. Your links will always point to the host they originated from. That should solve the problem you're facing.
Try using IIS / IIS-Express instead of Casinni web server that comes with visual studio.
You could add bindings to have the right URL (with host entries of course).
This will avoid the port numbers in your links.