Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions samples/http-to-https-redirect/.devproxy/devproxyrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.0.0/rc.schema.json",
"plugins": [
{
"name": "RewritePlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
"configSection": "rewritePlugin"
}
],
"urlsToWatch": [
"http://*"
],
"rewritePlugin": {
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.0.0/rewriteplugin.schema.json",
"rewritesFile": "rewrites.json"
}
}
13 changes: 13 additions & 0 deletions samples/http-to-https-redirect/.devproxy/rewrites.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.0.0/rewriteplugin.rewritesfile.schema.json",
"rewrites": [
{
"in": {
"url": "^http://(.*)"
},
"out": {
"url": "https://$1"
}
}
]
}
72 changes: 72 additions & 0 deletions samples/http-to-https-redirect/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Force HTTPS during development

## Summary

This sample demonstrates how to use Dev Proxy to automatically rewrite HTTP requests to HTTPS during development. This helps match production security locally and test against HTTPS without certificate hassles.

## Compatibility

![Dev Proxy v2.0.0](https://aka.ms/devproxy/badge/v2.0.0)

## Contributors

* [Waldek Mastykarz](https://github.com/waldekmastykarz)

## Version history

Version|Date|Comments
-------|----|--------
1.0|January 10, 2026|Initial release

## Minimal path to awesome

* Clone this repository (or [download this solution as a .ZIP file](https://pnp.github.io/download-partial/?url=https://github.com/pnp/proxy-samples/tree/main/samples/http-to-https-redirect) then unzip it)
* Start Dev Proxy: `devproxy`
* Test the rewrite by making HTTP requests that will be automatically redirected to HTTPS:
```bash
# This HTTP request will be rewritten to HTTPS
curl -ikx http://127.0.0.1:8000 http://jsonplaceholder.typicode.com/posts/1

# Dev Proxy will intercept the request and change it to:
# https://jsonplaceholder.typicode.com/posts/1
```

## Features

This sample provides a Dev Proxy configuration that rewrites HTTP requests to HTTPS:

**Rewrite Rules:**
* HTTP to HTTPS - Rewrites all `http://` URLs to `https://`

**Key Benefits:**
* **Match production security locally** - Ensure your development environment uses HTTPS just like production
* **Test against HTTPS without certificate hassles** - Dev Proxy handles the protocol rewriting transparently
* **Easy to customize** - Add more rewrite rules in `.devproxy/rewrites.json` for additional URL transformations

**Additional Rewrite Patterns:**
You can extend the `.devproxy/rewrites.json` file with additional patterns such as:
* Change API versions (v1 to v2)
* Redirect staging to production URLs
* Add/modify query parameters

Using this sample you can use the Dev Proxy to:

* Automatically force HTTPS for all HTTP requests during development
* Test HTTPS behavior without modifying your application code
* Ensure consistency between development and production environments

## Help

We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.

You can try looking at [issues related to this sample](https://github.com/pnp/proxy-samples/issues?q=label%3A%22sample%3A%20http-to-https-redirect%22) to see if anybody else is having the same issues.

If you encounter any issues using this sample, [create a new issue](https://github.com/pnp/proxy-samples/issues/new).

Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/proxy-samples/issues/new).

## Disclaimer

**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**

![](https://m365-visitor-stats.azurewebsites.net/SamplesGallery/pnp-devproxy-http-to-https-redirect)
8 changes: 8 additions & 0 deletions samples/http-to-https-redirect/assets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Screenshot Placeholder

A screenshot demonstrating Dev Proxy rewriting HTTP requests to HTTPS needs to be added to this folder.

The screenshot should:
- Be named `screenshot.png`
- Have a resolution of 1920x1080 (preferred)
- Show the terminal output of Dev Proxy intercepting an HTTP request and rewriting it to HTTPS
72 changes: 72 additions & 0 deletions samples/http-to-https-redirect/assets/sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[
{
"name": "pnp-devproxy-http-to-https-redirect",
"source": "pnp",
"title": "Force HTTPS during development",
"shortDescription": "Automatically rewrite HTTP requests to HTTPS during development using Dev Proxy. Match production security locally and test HTTPS without certificate hassles.",
"url": "https://github.com/pnp/proxy-samples/tree/main/samples/http-to-https-redirect",
"downloadUrl": "https://pnp.github.io/download-partial/?url=https://github.com/pnp/proxy-samples/tree/main/samples/http-to-https-redirect",
"longDescription": [
"Automatically rewrite HTTP requests to HTTPS during development using Dev Proxy. Match production security locally and test HTTPS without certificate hassles."
],
"creationDateTime": "2026-01-10",
"updateDateTime": "2026-01-10",
"products": [
"Dev Proxy"
],
"metadata": [
{
"key": "SAMPLE ID",
"value": "http-to-https-redirect"
},
{
"key": "PRESET",
"value": "Yes"
},
{
"key": "MOCKS",
"value": "No"
},
{
"key": "PLUGIN",
"value": "No"
},
{
"key": "PROXY VERSION",
"value": "v2.0.0"
}
],
"thumbnails": [
{
"type": "image",
"order": 100,
"url": "https://github.com/pnp/proxy-samples/raw/main/samples/http-to-https-redirect/assets/screenshot.png",
"alt": "Dev Proxy rewriting HTTP to HTTPS"
}
],
"authors": [
{
"gitHubAccount": "waldekmastykarz",
"pictureUrl": "https://github.com/waldekmastykarz.png",
"name": "Waldek Mastykarz"
}
],
"references": [
{
"name": "Get started with the Dev Proxy",
"description": "The tutorial will introduce you to the Dev Proxy and show you how to use its features.",
"url": "https://learn.microsoft.com/microsoft-cloud/dev/dev-proxy/get-started"
},
{
"name": "Use preset configurations",
"description": "Instructions on how to configure the Dev Proxy to use a different configuration file.",
"url": "https://learn.microsoft.com/microsoft-cloud/dev/dev-proxy/how-to/use-preset-configurations"
},
{
"name": "RewritePlugin documentation",
"description": "Technical reference documentation for the RewritePlugin.",
"url": "https://learn.microsoft.com/microsoft-cloud/dev/dev-proxy/technical-reference/rewriteplugin"
}
]
}
]
Loading