Please clarify a few basic points (answers to some items can be answered with just a set of keywords, I don’t know in which direction to look at all at the moment):

  1. If I suppose I wrote some kind of unpretentious web server on Go, then as I understand it, I need to fix it somewhere on the hosting. For this, I need to somehow move the binary to this host and how to describe the nginx configuration (let it be nginx) so that this nginx performs proxying to my server. How does this process occur at all?
  2. I learned that nginx gives static files directly from disk. How do I place these files on this disk?
  3. How can I set the port on which my server will hang in the code? After all, the host itself must somehow define the port of my service, and at the same time I need to specify it somehow in order to compile the sources (or it is specified as a parameter ...)
  4. How do I place the base on the host? Suppose I decided to use SQLite and it will eventually grow very much over time. Will there be any sanctions applied by the host, for what I devoured many resources at my base?
  5. What technology stack is desirable to know to pull the backend on go?

Closed due to the fact that the question is too general for the participants Ainar-G , D-side , Suvitruf , 0xdb , cheops 18 May '18 at 20:39 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

    1 answer 1

    1. In your case, it is easy to copy the file to the server. Usually hosters themselves indicate in which directory you can place user files. If the server is "personal / iron", then in principle you can place it anywhere, but in the case of go binaries, either in the home directory or in the web server folder for binaries. Also now it is fashionable to deploy via dockerfile.

    Actually you can copy the file to the server via ssh / sftp (the usual way), via ftp (the old way, but it is already dying), through the hosting administrator (perverted, but not enough).

    To make everything work, you need to first decide how it will work. You can, with nginx, you can and without. Sample setting .

    Nginx config example

    server { listen 80; server_name lesnoy.name; # домен location / { root /app/; include fastcgi_params; proxy_pass http://localhost:9001; } } 

    and in the go code you only need to listen to requests in the right place.

     http.ListenAndServe(":9001", nil) 
    1. Files you just need to copy to the right place. There is a lot of literature on this topic, just read any manual for php / python / web programmers.

    2. The port with which everything will be outside will be determined in your case by nginx ( listen 80 parameter listen 80 ). Where to listen locally to nginx and go to the binary in the example above is port 9001.

    3. If you decide to use the sqlite database, then for the host this is just a regular file. Therefore, if the base "grows", then most likely you will run into a limit on the size of the disk space, and possibly in the number of disk accesses. The file itself must simply be placed in a secluded place (so that it is not accessible from the outside world, but there is little that is suddenly needed).

    Will there be any sanctions applied by the host, for what I devoured many resources at my base?

    Yes, you just can not be written to the file. Most likely it will look as if the end of disk space.

    1. Naturally, you need to know a little go. It is advisable to know what HTTP / GET / POST requests are. Know a little HTML / javascript (theoretically, a backend developer can do without this, but in practice rarely are pure backends.)