Skip to content

Ercan Ermis

notes for everyone

Menu
  • Cloud
    • Amazon Web Services
    • Google Cloud Platform
  • Linux
  • DevOps
  • Docker
  • Uncategorized
  • Contact Me
Menu

Redirect 301 HTTPS on App Engine with nginx on Google Cloud Platform

Posted on April 15, 2021April 24, 2021 by Ercan

I started to play with App Engine on Google Cloud Platform these days. I’m using a flexible environment with a custom runtime to run PHP in Docker. App Engine serving the content via HTTP and HTTPS as well. I checked the disable HTTP or redirect the HTTP traffic easily to HTTPS via Web UI but unfortunately, it’s not possible right now. Yes, you heard right, the basic feature is not supporting!

I check the document for (https://cloud.google.com/appengine/docs/standard/php7/application-security) I tried to set a 301 redirect via app.yaml file. Here is what I tried:

handlers:
- url: /.*
  script: auto
  secure: always
  redirect_http_response_code: 301

I deployed a new version of my app but App Engine still serving via HTTP and it doesn’t redirect to HTTPS when I requested insecure connection.

This time, I decided to give a shot to nginx. I opened my nginx-app.conf file and I wrote this:

server_name _;

if ($http_x_forwarded_proto = "http") {
    return 301 https://$host$request_uri;
}

And Voila! It worked so perfectly. How I tried and understand this process you can see below.

➜  ~ curl -I http://ercan-ermis.ew.r.appspot.com/
HTTP/1.1 301 Moved Permanently
Date: Thu, 15 Apr 2021 07:03:34 GMT
Content-Type: text/html
Content-Length: 178
Server: nginx
Location: https://ercan-ermis.ew.r.appspot.com/
Via: 1.1 google

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • SSL CA Problem on CentOS7 Docker and Solution
  • What do I have?
  • I’m officially AWS Community Builder!
  • Deploy HA nginx to AWS ECS with Geolocation Routing via Terraform
  • Deploy nginx docker to AWS ECS with Terraform Automation
  • How to Install Node Exporter on Linux Server
  • FortiClient Problem on M1 MacBookPro Problem Solution
  • Connect your AWS to GCP with Terraform via IPSec Site-to-Site VPN
  • Google Cloud Platform Automation with Terraform Easily
  • How to secure your Amazon Web Services account
  • Install UGREEN USB Ethernet Adapter on macOS
  • Redirect 301 HTTPS on App Engine with nginx on Google Cloud Platform
  • Set two different Target Groups on AWS Load Balancer with Terraform
  • Extend your ec2 Linux disk without reboot on Amazon Web Services
  • Create a New Grant User on AWS RDS (MariaDB)
  • Amazon S3 CORS Settings with CloudFront on Amazon Web Services
  • Take your GitLab backup everyday if it works in Docker
  • Find large files in CentOS, ubuntu and MacOS easily
  • Fix “Error: rpmdb open failed” on CentOS or Amazon Linux 2
  • Error: No space left on the device when starting/stopping services only
  • Juniper SRX110H-VA VDSL2 Configuration Step by Step
  • Enable Logrotation for Docker Containers
  • Download specific file extension via wget easily on terminal
  • Find the exact size of certain files in Linux via terminal
  • Disable SELinux on CentOS 7 or CentOS 8
  • Hello Blog!

Tag Cloud

amazon linux 2 amazon web services automation aws aws community builder bug centos ci/cd cloud community connection container curl devops docker ec2 ecs fargate file size forticlient fortigate gcp gitlab google cloud platform ipsec isp juniper linux m1 macbookpro macos multi region network pipeline reliability route table security terraform turknet ubuntu vdsl2 vpn vpn problem vpn tunnel wget yum

Archive

  • March 2022 (1)
  • July 2021 (1)
  • May 2021 (6)
  • April 2021 (5)
  • February 2021 (1)
  • January 2021 (1)
  • September 2020 (2)
  • July 2020 (1)
  • April 2020 (1)
  • March 2020 (1)
  • February 2020 (1)
  • November 2019 (5)
©2022 Ercan Ermis | Built using WordPress and Responsive Blogily theme by Superb