I have a Rails app hosted in two different servers (both with dokku) for production and staging environments. The first one is hosted in www.mywebsite.com.br and the second one in www.staging.mywebsite.com.br.
We use a SSL certificate in production so I wrote
return 301 https://www.mywebsite.com.br$request_uri;
in my nginx.conf.sigil file so that every path redirects to the https URI. All working fine.
But now when I go to the staging environment, all URIs also redirect me to the https://www.mywebsite.com.br instead of http://www.staging.mywebsite.com.br. It makes sense, since I'm redirecting all requests in that line, but I can't seem to find a solution to configure my nginx.conf.sigil file for those two different needs.
Thanks a lot in advance and happy new year =)
You'll need a slightly separate nginx conf file for each server/environment, substituting in the correct domain name for each. You can see https://serverfault.com/questions/250476/how-to-force-or-redirect-to-ssl-in-nginx for more details and examples.
Related
I am working with a designer and I'd like them to have access to the interactions I've implemented on the site we're working on. However this time, I have 2 issues. My localhost is configured to a subdomain:
http://store.teststore:3000/ and we're on different networks. Is there anyway to work around this?
ngrok should work for you. Download and install it following these instructions here: https://ngrok.com/download. Documentation on how it is used can be found here https://ngrok.com/docs. Once installed running the below command should work for you (depending on the hosting environment):
ngrok http -host-header=rewrite store.teststore:3000
You will need to give the URL generated by ngrok and displayed in the cmd prompt to the designer.
Update: Handling absolute redirects
Based on your comment it sounds like, after login, your site does an absolute redirect (the full URL is specified). If it is possible I would change your code to do a relative redirect where the domain is omitted. You could also make your root domain configurable in the absolute redirect and configure it to be the ngrok domain provided for now. Lastly, you could attempt to configure your DNS with a CNAME record following ngroks Tunnels to custom domains documentation. This last option, however, requires a paid for ngrok subscription.
Install ngrok if you haven't yet and CD into your project directory and invoke ngrok. Note Your application must be running locally on the same port number ngrok will be running.
I'm getting the following error in the console when I try to get images from amazon S3, with my rails 5.2 app (with ActiveStorage) deployed on heroku:
GET https://www.myapp-production.herokuapp.com/rails/active_storage/representations/eyJfcmFpbHMiOnsibW[...]/image.jpeg net::ERR_CERT_COMMON_NAME_INVALID
I'm using heroku pipeline with 2 apps : myapp-staging (free dynos, no sll), and myapp-production(professional dyno + automatic ssl).
I've got a custom domain with ssl pointing to production app.
I can get images when I use the custom domain.
The problem occurs only when I use both staging/production.herokuapp.com/ domains.
Can't figure out what the problem is.
Thanks
If you expand the error info on the page, you'll get a more complete explanation:
This server couldn't prove that it's www.myapp-production.herokuapp.com; its security certificate is from *.herokuapp.com.
In certificates, a * only matches a single DNS label (e.g. containing no dots). So if you visit your app using myapp-production.herokuapp.com it will work, but to support navigating to the site with the www on the front, you will need to get a different certificate that includes the SubjectAltName *.myapp-production.herokuapp.com.
Thanks, that was de problem.
I was redirecting all request from non www to www subdomain to avoid duplicate content for SEO in my route file.
I turn it off for review and staging app and it's now working.
I don't really understand why the certificat was invalid only for images, though...
I have a RoR app hosted in Heroku and I'm trying to set my custom domains. In fact, I want three custom domains: www.myapp.org, www.myapp.eu and www.myapp.es.
I have configured my DNS to point to the DNS targets provided by Heroku. I have the .eu and .es domains registered in www.piensasolutions.com and the .org in cloudns.
The redirection works perfectly fine but I have discovered that ACM is unable to generate certificates for my .es domain. The other 2 work perfectly fine (.org and .eu) but the .es is failing. Even though is configured exactly the same as the .eu one, as they are both registered in the same site.
I have tried to see the status of the certifications using heroku certs:auto and it says "Failing" for the "www.myapp.es"
It was a matter of time. Seems like certificating a local domain like .es is slower for the Heroku ACM. After nearly 20h everything is set up. Sorry for the time waste.
I have several domains with domain.com , and it used to be if I want to set up a Heroku app with a domain bought at domain.com, all I have to do is point the cname to [name-of-heroku-app].herokuapp.com . And add the domain in Heroku.
But now, if I add a domain at Heroku, the DNS target will be [domain-name].herokudns.com . My older apps on heroku with a custom domain however have a DNS target of [name-of-heroku-app].herokuapp.com .
Am I doing something wrong? Can't seem to get the domain to work properly. Any help would be appreciated.
Nonetheless. Set the CNAME to [name-of-heroku-app].herokuapp.com and not [domain-name].herokudns.com.
I would wait a few hours as it depends on many circumstances how fast the change happens.
[domain-name].herokudns.com should be used, when you want to add SSL:
The DNS Target can be different from the Heroku Domain and different for each custom domain. For instance, if you add Heroku SSL on your application, your DNS target will be .herokudns.com, instead of .herokuapp.com.
Source
I've been working for a client's website over the past year. I usually test things locally and then deploy straight to the production website. This has caused us some issues lately so I thought I should create a test/staging environment in which we could thoroughly test new features before pushing them into production.
Anyway, we have a VPS hosting account. I usually use remote desktop to manage the website in IIS. So in order to create a test environment, I copy pasted the folder of the production website inside the same directory (so they are both at the same level) and changed the name of the folder. Then I created a new website in IIS and mapped the physical path to the httpdocs folder inside the copied folder. After that, I setup a new application pool which basically has the same settings of the production website's application pool. I also changed the connection string of the test website.
But then when I tried to view the test website, it did not work the way I expected it to do. I keep getting &ReturnUrl=%2f appended to the query string, and the website is stripped out of its styles (the CSS). I remember this used to happen before when we were still using a shared hosting account, but I have no idea how to fix that.
I really do not know what's wrong. I basically have the same exact setup except I'm using a different port and a different database. I even tried running the test website with the application pool of the production website, but that did not work either...
Any suggestions?
looks like permission problem to me, check if your user has correct privileges in the new folder/app pool :)