Skip to content

Instantly share code, notes, and snippets.

@ikurni
Last active May 28, 2020 15:24
Show Gist options
  • Save ikurni/dc8278600519b5a0f0d93c2d895e6a74 to your computer and use it in GitHub Desktop.
Save ikurni/dc8278600519b5a0f0d93c2d895e6a74 to your computer and use it in GitHub Desktop.
NGINX Config to do HTTPS redirect with Header change
edit file : /etc/nginx/nginx.conf
--------
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
server {
listen 443 ssl http2 default_server;
server_name _;
root /usr/share/nginx/html;
ssl_certificate /opt/server-cert2.pem; #need to provide ssl cert for 443
ssl_certificate_key /opt/server.key; #need to provide ssl key
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
}
}
}
---------
edit file: /etc/nginx/conf.d/default.conf
---------
upstream cloud.dc.example.com {
server console-openshift-console.apps.prdocp.dc.pq.example.com;
}
server {
listen 443;
server_name cloud.dc.example.com;
location / {
# sub_filter_once off;
# sub_filter '//console-openshift-console.apps.prdocp.dc.pq.example.com/' '//cloud.dc.example.com/';
proxy_set_header Host console-openshift-console.apps.prdocp.dc.pq.example.com;
proxy_set_header Accept-Encoding "";
proxy_cookie_domain console-openshift-console.apps.prdocp.dc.pq.example.com cloud.dc.example.com;
proxy_pass https://console-openshift-console.apps.prdocp.dc.pq.example.com;
}
}
---------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment