Skip to content

Instantly share code, notes, and snippets.

View bidipeppercrap's full-sized avatar
🙂

Stupendously Stupid bidipeppercrap

🙂
View GitHub Profile
@bidipeppercrap
bidipeppercrap / please.typ
Last active September 24, 2023 13:13
Please - A Request for Quotation template
= Request for Quotation
#datetime.today().display("[day] [month repr:long] [year]")
#block(
fill: luma(230),
inset: 10pt,
[
😀 Fransisco Wijaya \
📞 #link("https://wa.me/+6285171719191")[0851 7171 9191] \
📧 #link("mailto:fransiscowijaya1999@gmail.com")

Cloudflare + Nginx Origin Certificate SSL Setup

Step 1 - Generating an Origin Certificate

First thing to do is to create your certificate on Cloudflare:

  1. On your website dashboard, go to SSL/TLS > Origin Server
  2. On Hostnames section, change the hostnames to your domains or subdomain. e.g. tobako.bidipeppercrap.com
  3. On Origin Certificates section, press the Create Certificate button
  4. Leave the default settings and press Next
  5. Copy the PEM certificate to your server: /etc/ssl/certs/your.domain.com.pem

Calling gRPC Service from Custom Domain with Nginx and .NET gRPC-Web

Prequisites

  • Setup your .NET application with gRPC-Web & CORS enabled.
  • Setup SSL for your domain.

1. Configure HTTP2

Add http2 after ssl in your server block config:

listen [::]:442 ssl http2 ipv6only=on;
static_resources:
listeners:
- name: listener_browser
address:
socket_address: { address: 0.0.0.0, port_value: 10000 }
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager

Securing Nginx with Let's Encrypt on Ubuntu

Suppose we have configured our Nginx server block with this simplest form of config:

upstream service_api {
    localhost:3000;
}

server {
 listen 80;

Docker Network

Most of the time, you want to change on which network the containerized app has to listen.
For example, we want to containerized app to listen on localhost:5000 of our machine (host).
We run the docker with --network="host" so the containerized app will listen to the host network instead of its own container network.

docker run --network="host" -d --name myapp myimage

Using host network will remove port binding of the container.

@bidipeppercrap
bidipeppercrap / ssh-tunneling.md
Last active July 28, 2020 16:15
Expose localhost to remote server using SSH and Nginx

SSH Tunneling

Case

I want to expose my localhost:5000 to my remote server ip <ip>:3000 (Optionally with domain).

Answer

In terminal, run this command: ssh -f -N -T -R 5000:localhost:3000 user@<server-ip>
You must be seeing your pointer stuck in the terminal.