I am using nginx to reverse proxy to a web server written with go, but the page does not appear due to a title error.
default.conf
server{
listen80;
server_name localhost;
# charset koi8-r;
# access_log/var/log/nginx/log/host.access.log main;
location / {
# root/usr/share/nginx/html;
# index index.html index.htm;
proxy_pass http://127.0.0.1:60000/;
}
# error_page404/404.html;
# redirect server error pages to the static page /50x.html
#
error_page500502503504/50x.html;
location=/50x.html{
root/usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
# location~\.php${
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1—9000
#
# location~\.php${
# roottml;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME/scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to.htaccess files, if Apache's document root
# concurs with nginx's one
#
# location~/\.ht{
# deny all;
#}
}
go's main function
package main
import(
"github.com/labstack/echo"
mw "github.com/labstack/echo/middleware"
"github.com/thoas/stats"
"os"
)
funcmain(){
e: = echo.New()
// Middleware.
e.Use(mw.Logger())
e.Use(mw.Recover())
e.Use(mw.Gzip())
s: = stats.New()
e.Use(s.Handler)
// Index page.
e.Index("public/")
// Static files.
e. Static("/js", "public/js")
e. Static("/css", "public/css")
e. Static ("/images", "public/images")
if port: =os.Getenv("PORT"); port!="{
e.Run(":"+port)
} else{
e.Run (":3000")
}
}
The Go web server program is located below /var/www/html/[page-name]
.
I checked it locally, but it was displayed properly.
When I tried accessing it
INFO|echo|127.0.0.1 GET/20051.487429ms13820
INFO|echo|127.0.0.1 GET/2009.556293ms13820
INFO|echo|127.0.0.1 GET/2008.84661ms13820
This is how it appears on the console, but the page does not appear. Why is it not?
nginx.conf
usernginx;
worker_processes1;
error_log/var/log/nginx/error.log warn;
pid/var/run/nginx.pid;
events {
worker_connections1024;
}
US>http{
include/etc/nginx/mime.types;
default_type application/octet-stream;
log_format main'$remote_addr-$remote_user[$time_local]"$request"'
'$status$body_bytes_sent"$http_refer"'
'''$http_user_agent''''$http_x_forwarded_for";
access_log/var/log/nginx/access.log main;
sendfile on;
# tcp_nopush on;
keepalive_timeout65;
#gzip on;
include/etc/nginx/conf.d/*.conf;
}
Additional error_log
February 11, 2016 04:32:39 [notice] 29316#0:signal process started
February 11, 2016 04:32:45 [alert] 23756 #0:worker process 29319 expired on signal 11
February 11, 2016 04:32:46 [alert] 23756 #0:worker process 29324 expired on signal 11
February 110 07:09:02 [error] 29320 #0:*241 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.10.100, server:localhost, request: "GET/HTTP/1.1", upstream: "http://127.0.0.1:60000/", host:10.1682.
There were a lot of things like the one above.
Server side port 80 tcpdump result
01:02:40.058334 IP (tos0x0, ttl64, id33406, offset0, flags [DF], proto TCP(6), length471)
192.168.10.100.56136> 192.168.10.105.http: Flags [P.], cksum0x9494 (correct), seq1:420, ack1, win4117, options [nop, nop, TSval300422591ecr15850679], length 419
[email protected]@....
d..
i.H.P..Y....X........
........GET/HTTP/1.1
Host: 192.168.10.105
Connection:keep-alive
Cache-Control: max-age = 0
Accept: text/html, application/xhtml+xml, application/xml;q=0.9, image/webp, */*;q=0.8
Upgrade-Insecure-Requests:1
User-Agent: Mozilla / 5.0 (Intel Mac OS X 10_11_3) Apple WebKit / 537.36 (KHTML, like Gecko) Chrome / 47.0.2526.111 Safari / 537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: ja, en-US; q = 0.8, en; q = 0.6
I'm afraid I'm complimenting myself, but I worked with this kind of implementation.
Both local (or VM) and remote environments have been verified.
https://github.com/syo-sa1982/GoNTAkun/blob/master/main.go
By the way, the nginx setting is
Only default.conf is the same as the questioner, and I have not touched anything else.
I hope it will be helpful.
342 Memory layouts learned in theory don't work out as expected when actually printed as addresses.
356 Unity Virtual Stick Does Not Return to Center When You Release Your Finger
341 Understanding the Meaning of mpm prefork Settings
367 To Limit Column Values to Strings in a String List Using sqlalchemy
356 I want to create an array of sequences from "1" to a specified number.
© 2023 OneMinuteCode. All rights reserved.