0

I am following https://gist.github.com/mcxiaoke/055af99e86f8e8d3176e

server {
  # Git repos are browsable at http://example.com:4321/
  listen 4321 default;   # Remove 'default' from this line if there is already another server running on port 80
  server_name example.com;

  location /index.cgi {
    root /usr/share/gitweb/;
    include fastcgi_params;
    gzip off;
    fastcgi_param SCRIPT_NAME $uri;
    fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
    fastcgi_pass  unix:/var/run/fcgiwrap.socket;
  }

  location / {
    root /usr/share/gitweb/;
    index index.cgi;
  }
}

Why is my web browser connecting to http://example.com:4321/ forever, while can immediately connect to http://localhost:4321/?


I found a solution from https://unix.stackexchange.com/a/188193/674: add to my /etc/hosts:

127.0.0.1 localhost www.example.net

I can now connect to www.example.net in Google chrome browser, but not in firefox:

Secure Connection Failed

An error occurred during a connection to www.example.com:4321. SSL received a record that exceeded the maximum permissible length. Error code: SSL_ERROR_RX_RECORD_TOO_LONG

The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
Please contact the website owners to inform them of this problem.

and the URL in the address bar is always "https://www.example.com:4321/" when I paste www.example.com:4321/.

Why does the change work for Chrome? Why not for firefox?

Thanks.

2
  • Do you have example.com resolving locally differently? Otherwise you'll be heading to an Internet site on a port that's probably not listening ...
    – Jeff Schaller
    Jan 19 '19 at 16:55
  • www.example.com (on port 80) says: Example Domain -- This domain is established to be used for illustrative examples in documents. You may use this domain in examples without prior coordination or asking for permission.
    – Jeff Schaller
    Jan 19 '19 at 16:56
1

You should set resolving for your host as I describe in this Q/A

About server_name in nginx: It work as option to create virtual hosts which listen to same IP and same port. And the only way to distinguish them is via hostname resolv. You can find more info about virtual hostings and server_name here

You can try in firefox to write http://www.example.com:4321 Also you can check this Q/A

2
  • Thanks. Why does my change work for Chrome? Why not for firefox?
    – Tim
    Jan 19 '19 at 20:12
  • @Tim, please check my edited answer Jan 20 '19 at 5:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.