Guys I fixed it with some NGINX configuration and BasicAuth, I set TXT RECORD that provided by Postman for my domain in DNS resolver (Bind, Route53, …) and handle CNAME Record redirection with NGINX.
for example if you have a sub domain (ex: docs.example.com) that you want to show your Postman Published collections you should set a CNAME record which point to your host instead of
phs.getpostman.com so we can handle it with NGINX rather than DNS resolver.
So Now create an NGINX conf in /etc/nginx/conf.d
or anywhere you install NGINX:
you can check these configuration on my Github gist Add BasicAuth to Postman Published Collection on Custom Domains · GitHub
# IF you want to Setup ON SSL Configuration
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name docs.example.com;
# SSL Configuration
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_certificate /path/to/fullchain.pem;
ssl_certificate_key /path/to/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers HIGH:!aNULL:!MD5;
auth_basic "Restricted Area";
auth_basic_user_file /path/to/.htpasswd;
location / {
proxy_pass https://phs.getpostman.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_intercept_errors on;
}
}
# IF you want to Setup ON non-SSL Configuration
server {
listen 80;
listen [::]:80;
server_name docs.example.com;
auth_basic "Restricted Area";
auth_basic_user_file /path/to/.htpasswd;
location / {
proxy_pass https://phs.getpostman.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_intercept_errors on;
}
}
Hope it helps someone.