Score:1

NGINX 302 redirect / proxy

ec flag

I have an icecast server that runs on port 8000 however when I set up a proxy using NGINX I seem not to be able to make it look like it is the original server.

I am wondering is there anyway to kinda like make a NGINX that is parked and pointed at port 8000 but allow traffic from port 80

 server {
  listen 80;
  listen [::]:80;
  server_name example.com;

  gzip on;
  gzip_proxied any;
  gzip_comp_level 4;
  gzip_types text/css application/javascript image/svg+xml;

  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection 'upgrade';
  proxy_set_header Host $host;
  proxy_cache_bypass $http_upgrade;


 location / {
  proxy_pass http://127.0.0.1:8000/;
 }
}

I have also tried

 server {
  listen 80;
  listen [::]:80;
  server_name onlineradio.example.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 X-Forwarded-Host $host;
  proxy_set_header X-Forwarded-Server $host;

 location / {
  proxy_set_header Accept-Encoding "";
  proxy_pass http://127.0.0.1:8000/;
  sub_filter_types application/xspf+xml audio/x-mpegurl audio/x-vclt text/css text/html text/xml;
  sub_filter ':8000/' '/';
  sub_filter '@localhost' '@onlineradio.example.com';
  sub_filter 'localhost' $host;
  sub_filter 'Mount Point ' $host;
 }
 }

however when I then try and connect to it via my Nodejs app it does not load when using the package var icecast = require('icecast-stack')

I know that plugin looks for icy-metaint which is a header that icecast streams have.

From my understand my NGINX needs to pass that header

The headers I need to pass are they are from https://stream.radiomedia.com.au:8003/stream

Headers(16) °
  °String: 'Server: Icecast 2.4.4'é à
    key: 'Server',
    value: 'Icecast 2.4.4'
  è,
  °String: 'Connection: Close'é à key: 'Connection', value: 'Close' è,
  °String: 'Date: Tue, 08 Nov 2022 06:53:55 GMT'é à
    key: 'Date',
    value: 'Tue, 08 Nov 2022 06:53:55 GMT'
  è,
  °String: 'Content-Type: audio/mpeg'é à
    key: 'Content-Type',
    value: 'audio/mpeg'
  è,
  °String: 'Cache-Control: no-cache, no-store'é à
    key: 'Cache-Control',
    value: 'no-cache, no-store'
  è,
  °String: 'Expires: Mon, 26 Jul 1997 05:00:00 GMT'é à
    key: 'Expires',
    value: 'Mon, 26 Jul 1997 05:00:00 GMT'
  è,
  °String: 'Pragma: no-cache'é à key: 'Pragma', value: 'no-cache' è,
  °String: 'icy-br:128'é à key: 'icy-br', value: '128' è,
  °String: 'ice-audio-info: ice-samplerate=44100;ice-bitrate=128;ice-channels=2'é à
    key: 'ice-audio-info',
    value: 'ice-samplerate=44100;ice-bitrate=128;ice-channels=2'
  è,
  °String: 'icy-br:128'é à key: 'icy-br', value: '128' è,
  °String: 'icy-description:The Sound Of Indie'é à
    key: 'icy-description',
    value: 'The Sound Of Indie'
  è,
  °String: 'icy-genre:indie'é à key: 'icy-genre', value: 'indie' è,
  °String: 'icy-name:DRN1'é à key: 'icy-name', value: 'DRN1' è,
  °String: 'icy-pub:1'é à key: 'icy-pub', value: '1' è,
  °String: 'icy-url:http://DOMAIN GO HERE à
    key: 'icy-url',
    value: 'http://DOMAIN GO HERE.com'
  è,
  °String: 'icy-metaint:16000'é à key: 'icy-metaint', value: '16000' è,
  server: 'Icecast 2.4.4',
  Server: 'Icecast 2.4.4',
  connection: 'Close',
  Connection: 'Close',
  date: 'Tue, 08 Nov 2022 06:53:55 GMT',
  Date: 'Tue, 08 Nov 2022 06:53:55 GMT',
  'content-type': 'audio/mpeg',
  'Content-Type': 'audio/mpeg',
  'cache-control': 'no-cache, no-store',
  'Cache-Control': 'no-cache, no-store',
  expires: 'Mon, 26 Jul 1997 05:00:00 GMT',
  Expires: 'Mon, 26 Jul 1997 05:00:00 GMT',
  pragma: 'no-cache',
  Pragma: 'no-cache',
  'icy-br': '128',
  'ice-audio-info': 'ice-samplerate=44100;ice-bitrate=128;ice-channels=2',
  'icy-description': 'The Sound Of Indie',
  'icy-genre': 'indie',
  'icy-name': 'DOMAIN',
  'icy-pub': '1',
  'icy-url': 'http://DOMAIn GIO here.com',
  'icy-metaint': '16000'
TBR avatar
de flag
TBR
Reverse proxying Icecast is very much NOT straight forward and because of that not recommended. Having Icecast listen on ports 80/443 is preferred if possible. – That said, someone has posted their - quite complex - nginx reverse proxy configuration as an answer on stackoverflow a long time ago.
Score:0
de flag
TBR

There have been previous questions on this topic

Generally it is not recommended to reverse proxy Icecast as it is very hard to cover all bases and make things work correctly. Things can break in subtle and unexpected ways.

That said, someone has posted their NginX setup to StackOverflow, but again this is very much non-trivial.

It is much easier to make Icecast listen to ports 80 and 443 instead. However this requires a dedicated IP-address to work.

RussellHarrower avatar
ec flag
Yes, the issue is we have 6 stations using the same VPS we only want the proxy for our apps and websites to connect to, and also allows us to hide the icecast web interface.
TBR avatar
de flag
TBR
If that's what you want then you'll have to invest the work into replicating that nginx setup. BTW: Icecast auth can be used to apply to the web interface too, not just to mount points.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.