I am trying to set up a simple custom website. I have built a simple server using Golang and the Gin-gonic framework. My Go server is as follows:
func main() {
r := gin.Default()
r.GET("/", ServeMainPage)
r.GET("/icons/openlogo-75.png", func(c *gin.Context) {
c.File("favicon.ico")
})
r.GET("/episode/:id", ServeEpisode)
r.GET("styles/style.css", func(c *gin.Context) {
c.File("styles/style.css")
})
r.GET("scripts/main.js", func(c *gin.Context) {
c.File("scripts/main.js")
})
r.GET("favicon.ico", func(c *gin.Context) {
c.File("favicon.ico")
})
r.Run()
}
func ServeMainPage(c *gin.Context) {
c.File("index.html")
}
func ServeEpisode(c *gin.Context) {
episodeID := c.Param("id")
filepath := "AudioFiles/" + episodeID + ".mp3"
c.File(filepath)
}
Because this process cannot access port 80 (it runs on :8080), and because I am trying to develop my skills, I have attempted to set-up an nginx server to act as a reverse proxy. My nginx server has the following conf, which is the default,
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
and I followed the tutorial here to have it forward things to my Golang app by adding the following to /etc/nginx/sites-available/ro
and symbolic linking that to /etc/nginx/sites-enabled/ro
.
server {
listen 80;
server_name running-oaks.com;
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_pass "http://127.0.0.1:8080";
}
}
If I use curl on my local PC to access my server, I get the index.html page I would like it to server. My curl command is simply curl http://123.123.123.123
, where 123.123.123.123
is replaced by the actual IP of my remote server.
However attempting to access this same IP address with my web browser simply shows me the default Apache for Debian page. I uninstalled apache before setting up nginx in order to hopefully avoid conflicts. In both the curl case and the browser case, I can see that my Golang app is receiving the requests and returning a status 200.
So why does my browser keep showing me the debian page?
I have also changed /var/www/index.html
to be the default nginx page, although that hasn't fixed it either.